本文主要是介绍SELECT list is not in GROUP BY clause and contains nonaggregated incompatible with sql_mode=group_by,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
SELECT list is not in GROUP BY clause and contains nonaggregated column incompatible with sql_mode=only_full_group_by
这个报错是执行有GROUP BY的语句时出现的,原因是MySQL启用了默认的only_full_group_by SQL模式,导致GROUP BY语句报错.
执行select @@sql_mode可以看到sql_mode的值为
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
执行如下两句SQL即可:
set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
再执行:
set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
OK!问题解决!不会的给我私信!
觉得有帮助的可以关注一波!经常分享编程踩坑经验!
这篇关于SELECT list is not in GROUP BY clause and contains nonaggregated incompatible with sql_mode=group_by的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!