nonaggregated专题

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语句报错. 执行

MySQL: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'sss

今天在执行MySQL中sql语句的时候报错了,执行的sql语句: SELECTprov_desc,area_desc,month_id,MAX(total_fee)AS max_total,FROMsssWHEREprov_id = '075'OR prov_id IN('017')AND month_id IN('201207')GROUP BYprov_id,prov_desc,

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'name'

问题出现的原因: MySQL 5.7.5及以上功能依赖检测功能。如果启用了ONLY_FULL_GROUP_BY SQL模式(默认情况下),MySQL将拒绝选择列表,HAVING条件或ORDER BY列表的查询引用在GROUP BY子句中既未命名的非集合列,也不在功能上依赖于它们。(5.7.5之前,MySQL没有检测到功能依赖关系,默认情况下不启用ONLY_FULL_GROUP_BY。有关5.7.

MySQL报错:SELECT list is not in GROUP BY clause and contains nonaggregated column,解决ONLY_FULL_GROUP_BY

报错截图 解决方法:修改数据库配置 1.查看.sql_mode配置 select @@global.sql_mode; 2.查看返回信息是否包含ONLY_FULL_GROUP_BY ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION; 3.去掉ONLY_FULL_GROUP_BY ,其他参数不变,执行