Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
时间: 2023-11-05 18:05:10 浏览: 105
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘grades.order_id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by这个错误是由于在使用GROUP BY语句时,SELECT列表中的表达式#1不在GROUP BY子句中,并且包含非聚合列"grades.order_id",这与sql_mode=only_full_group_by不兼容所导致的。在MySQL版本5.7之后,默认的模式是ONLY_FULL_GROUP_BY,所以这个错误会出现。解决这个问题的方法是,要么将SELECT列表中的表达式#1添加到GROUP BY子句中,要么将sql_mode设置为一个不包含only_full_group_by的模式。
阅读全文