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 语句。