0
さまざまなsensornodesの異なるMAX(値)を選択したいと思います。私の問題は、WHERE ... IN ...節は多くの論理ORと同じように機能しますが、各センサーノードからMAX($ measure)が必要です。私はループでそれをする方法を知っていますが、私はこれを行うためのより良い解決策があると思います。アレイに応じて異なるMAX(値)を選択してください
ID humidity temperature date time sensornode
---------- ---------- ----------- ---------- ---------- ----------
1 22.00% 18.00C 06/03/2017 13:07:18 WSN1
2 22.00% 18.00C 06/03/2017 13:08:19 WSN2
3 34.00% 21.00C 06/03/2017 13:09:19 WSN3
4 21.00% 20.00C 06/03/2017 13:10:19 WSN4
は、クエリは、各センサノード、使用グルーピングの最大値を取得するために、この
$measure //is either 'temperature' or 'humidity', depends on the users input.
$sensornode // is a string which is converted with the implode-function from an array which includes the selected 'sensornodes' of the users input
$sql_query = "SELECT MAX($measure) AS $measure
FROM measurement
WHERE sensornode IN ('$sensornode')";
$data = executeQuery($sql_query, $measure);