[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

安装了mysql5.7,用group by 查询时抛出如下异常:关于mysql由低版本升级到5.7.25遇到的坑:


[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column '01shendongqilu.sap_interface_delivery_order.out_order_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


原因:

      MySQL 5.7.5和up实现了对功能依赖的检测。如果启用了only_full_group_by SQL模式(在默认情况下是这样),那么MySQL就会拒绝选择列表、条件或顺序列表引用的查询,这些查询将引用组中未命名的非聚合列,而不是在功能上依赖于它们。(在5.7.5之前,MySQL没有检测到功能依赖项,only_full_group_by在默认情况下是不启用的。关于前5.7.5行为的描述,请参阅MySQL 5.6参考手册。)
 

解决:

这两个命令,去掉 sql_mode 的 ONLY_FULL_GROUP_BY


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';


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';

 


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/fansili/article/details/78664267

 

 

 

你可能感兴趣的:([Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum)