1055 Expression #1 of SELECT list is not in GROUP BY clause
mysql使用group by 报错:
Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'XXX.Y.ZZZZ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
@xcy
文中链接的解决方案实际上是错的,它仅仅是让SQL语句不报错了。 当出现文中的错误时,说明写的GROUP BY SQL语句有歧义,MySQL不知道取哪一个数据。MySQL5.7开始有only_full_group_by实际上是为了修复之前的bug。
如果是新项目,正确做法是修改写的GROUP BY SQL语句。