2017-09-29 57 views
0
select host_city,max(city) as res 
from (
    select count(host_city) as city 
    from match_results 
    group by host_city 
) a 
LIMIT 0, 1000 

我收到此错误,当列表host_city确实存在于我的表中。错误在mysql查询中。需要获得城市名称和最大匹配在该城市中播放

错误代码:1054.'字段列表'中的未知列'host_city'。

我在mysql中

+0

我不确定最后一个'a',它是什么? – user10089632

+0

@ user10089632你认为它可能是什么? – Strawberry

+0

@visible请参阅https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple- sql-query – Strawberry

回答

0

这样做,你正在做一个SELECTFROM一个子SELECT。 Subselect基本上成为你的表格,而你的子选择没有host_city作为字段。这里是你需要的(如果你真的需要一个MAX - 我不确定我遵循你的逻辑)

select host_city,max(city) as res 
from (
    select host_city, count(host_city) as city 
    from match_results 
    group by host_city 
) a 
GROUP BY host_city 
LIMIT 0, 1000 
相关问题