[Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

[Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'epms.lk.item_fid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

今天把原测试数据库上的数据库导入到新的生产数据库中,启动项目访问时报错了,经过一番分析和查阅资料,最终找到原因是:我原来的数据库版本是5.5,新的生产数据库的版本是5.7以上的,sql的默认模式配置是ONLY_FULL_GROUP_BY,大概意思可能就是如果有用到sum,counts之类的聚合函数,要把字段都加入group by里吧。顺着这个思路把SQL语句改一改。

[Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated colum_第1张图片

然后在navicat执行没报错,顺利查询结果!特此记录,以便遇坑者查找借鉴。

你可能感兴趣的:(mysql)