当我们编写查询SQL使用group by,还查询了其他字段时,会提示group by限制的问题,如图所示:
错误代码: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'qrcode.store_storage.odd_desp' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
如果条件允许,就在my.ini或my.cnf里配置取消掉group by限制,如果不行就在其他字段(未在group by上声明的字段)上添加max()函数即可解决: