Mysql only_full_group_by以及其他关于sql_mode原因报错详细解决方案

ERROR 1055 (42000): Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘DATABASE.TABLE.ID’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

命令行界面执行sql:
1、输入:SELECT @@GLOBAL.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
2、然后我们来修改sql_mode
输入: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’;
3、再运行你的sql,ok了。

发表评论

电子邮件地址不会被公开。 必填项已用*标注