Mysql5.7查询数据group by分组时报错

mysql5.7查询数据group by分组时报错
错误代码:1055
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'chaichaile.task001_bank.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
解决问题
先进入Mysql客户端执行命令
select @@GLOBAL.sql_mode;
+------------------------------------------------------------+ 
| @@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                    
+------------------------------------------------------------+
在服务器上找到my.cnf,在[mysqld]下面添加查询出来的值删除ONLY_FULL_GROUP_BY
[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
重启mysql 服务。

您可以选择一种方式赞助本站

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: