小陆同学

python 中文名:蟒蛇,设计者:Guido van Rossum

导航

mysql5.7--sql_mode ONLY_FULL_GROUP_BY问题

(1055, "Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'XX' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by")

 

MySQL 5.7和up实现了对功能依赖的检测。如果启用了only_full_group_by SQL模式(在默认情况下是这样),那么MySQL就会拒绝选择列表、条件或顺序列表引用的查询,这些查询将引用组中未命名的非聚合列,而不是在功能上依赖于它们

 

解决方法一:

  取消/etc/my.cnf里的sql_mode

解决方法二:(亲测有效)

# 1、 mysql> 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';
# 2、 mysql> 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';
# 3、 set @@sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

感谢!https://blog.csdn.net/chai1230/article/details/89514482

 

posted on 2020-03-03 21:18  小陆同学  阅读(281)  评论(0编辑  收藏  举报