报错信息:
1055 - Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘fbjs.mscc.ContactTime’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by, Time: 0.000000s
报错原因:
在mysql5.7以上的版本中,对于 group by 的这种聚合操作,如果在select 中的列,没有在group by 中出现,那么这个SQL是不合法的,因为列不在group by的从句中,所以对于设置了这个mode的数据库,在使用group by 的时候,就要用MAX(),SUM(),ANT_VALUE()的这种聚合函数,才能完成GROUP BY 的聚合操作。
解决方法:
方法一:修改sql语句
把所有除了有聚合函数的字段都加在select后面的查询结果里。
方法二:修改数据库临时配置
执行sql语句:
set sql_mode =