报错大概如下:
"Error 1055: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'xxx' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by"
解决方式就是将 sql_mode
中的only_full_group_by
去掉。
我的处理方式是直接在执行group by
操作之前执行如下SQL语句,使得对当前查询有效,不影响全局。
SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
select * from xxx group by xxx;
参考