我无法从列数据中读取记录,为什么? 代码:
$_query = mysqli_query($mysqli , "SELECT o.id,o.surname,o.name,so.data FROM mowcy AS o
LEFT JOIN zeb AS so ON so.id=o.id AND so.mowca=o.mowca
WHERE
o.archiwum = 0
AND o.id<>1
AND o.mowca = 3
GROUP BY o.id
ORDER BY ISNULL(o.id) desc, MAX(so.data) ")
or die(mysqli_error($mysqli));
显示错误:
list不在GROUP BY子句中,包含非聚合列 'rafik73_tereny.so.data'在功能上不依赖于 GROUP BY子句中的列;这是不相容的 的sql_mode = only_full_group_by
答案 0 :(得分:2)
试试这个;
SELECT o.id,MAX(so.data) FROM mowcy AS o
LEFT JOIN zeb AS so ON so.id=o.id AND so.mowca=o.mowca
WHERE
o.archiwum = 0
AND o.id<>1
AND o.mowca = 3
GROUP BY o.id
ORDER BY ISNULL(o.id) desc, MAX(so.data)
由于在您的查询中对某些内容进行分组时错误会指向您,您应该只选择分组字段和聚合列。