mysql:sql_mode=“only_full_group_by”
程序员文章站
2023-12-28 10:13:16
...
select name,gmt_created from db_test group by name
数据库里调用如上sql,结果出错,显示“SELECT list is not in GROUP BY clause and contains nonaggregated column”
意思是让我改成
select name,gmt_created from db_test group by name,gmt_created
如上,那就失去了原来分组的意义了,原因是数据库配置sql_mode=“only_full_group_by”,
在不能修改数据库配置的情况下,用了distinct解决问题
推荐阅读