Mysql解决SELECT list is not in GROUP BY clause and contains nonaggregated column 问题
程序员文章站
2023-12-28 15:03:40
...
解决办法:
三步走,实测有效!!!
1:--查看数据库sql查询模式
select @@GLOBAL.sql_mode;
2:-- 去除only_full_group_by 模式设置,保留第一步查询出来的其他配置项
set GLOBAL sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
set SESSION sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
3:重启自身项目重新加载数据库配置即可!
原因:
MYSQL5.7.x版本默认开启了only_full_group_by 查询模式,不允许需要group by的字段后跟其他字段。
如果想要保留该模式,可以尝试在需要group by字段的后边使用any_value(其他字段),这个方式参考网友答案,个人未经尝试
推荐阅读
-
Mysql解决SELECT list is not in GROUP BY clause and contains nonaggregated column 问题
-
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column xxxx
-
Mysql数据库报错:select list is not in group by clause and contains .....sql_mode=only_full_group_by问题
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.
-
报错 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated
-
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains解决
-
linux上,mysql使用聚合函数group by 时报错:SELECT list is not in GROUP BY clause and contains nonaggre的问题
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
-
【问题解决】Expression #30 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'zxj