我从Godaddy升级为Blue Host,现在出现此错误:
语法错误或访问冲突:1055 SELECT列表的表达式#2不在GROUP BY子句中,并且包含未聚合的列'customeTable.fromuser',该列在功能上不依赖于GROUP BY子句中的列;这与
中的sql_mode = only_full_group_by'不兼容
$statement = $db->prepare("SELECT * FROM(SELECT DISTINCT(thread_id) AS
thread_id, fromuser, touser, aDeleted, bDeleted, avatar, message, seen,
time FROM conversations WHERE fromuser=:username AND bDeleted=0 OR
touser=:username AND aDeleted =0 ORDER BY time DESC) customeTable GROUP
BY thread_id ORDER BY time DESC");
$statement->bindParam("username", $username, PDO::PARAM_STR) ;
$statement->execute();
答案 0 :(得分:1)
要解决该查询,请查看以下内容:
GROUP BY
子句,没有任何聚合函数(您可能应该删除它)。参见documentation。DISTINCT
修饰符不是函数。它将删除所有列上的重复行AND
和OR
时,应使用括号,否则可能会得到意外的结果