在功能上不依赖于 group by 子句中的列,这与 sql_modeonly_full_group 不兼容

问题描述 投票:0回答:1
select countrycode,name, max(population) 
from city 
group by CountryCode LIMIT 0, 1000  

错误代码:1055。SELECT 列表的表达式 #2 不在 GROUP BY 子句中,并且包含非聚合列“world.city.Name”,它在功能上不依赖于 GROUP BY 子句中的列;这与 sql_mode=only_full_group_by 0.000 秒不兼容

帮我解决这个问题

mysql sql mysql-error-1055
1个回答
0
投票

如错误消息所述,您需要为所有列选择一个聚合函数n,否则它们必须在

GROUP BY

在你的情况下也把它放在

GROUP BY

select countrycode,name, max(population) 
from city 
group by CountryCode,name LIMIT 0, 1000  
© www.soinside.com 2019 - 2024. All rights reserved.