Когда я использую такой оператор OR:
Код: Выделить всё
$query = "
SELECT
ec.ElecEnergy,
ec.GasEnergy,
ua.City,
SUM(ec.ElecEnergy) AS ecTotal,
SUM(ec.GasEnergy) AS gcTotal
FROM energyconsumption ec
INNER JOIN useraccount ua ON ec.User = ua.id
WHERE
ua.City ='London'
OR City ='Manchester'
OR City ='Luton'
OR City ='Newcastle'
OR City ='Birmingham'
OR City ='Blackburn'
GROUP BY ec.ElecEnergy, ec.GasEnergy, ua.City
ORDER BY ec.ID ASC
";
$result = mysqli_query($conn,$query);
$r = array();
if ($result->num_rows) {
while ($row = mysqli_fetch_array($result)) {
array_push($r, array(
'ElecConsump' => $row['ecTotal'],
'GasConsump' => $row['gcTotal'],
'Location' => $row['City']
));
}
}
echo json_encode(array('results' => $r));
Я не уверен, что делаю неправильно.
Подробнее здесь: https://stackoverflow.com/questions/417 ... re-clauses
Мобильная версия