I have a database which will receive a whole bunch of information, but most importantly it will receive a city name for each row. Sample below:
id city
1 London
2 Manchester
3 London
4 Brighton
5 Oxford
6 Oxford
7 London
I want to SELECT only the city name from this table, displaying the top 3 results in the order of which occurs most often.
So far I am using the query below which I found:
SELECT N.city, COUNT(*) AS howmany
FROM ( SELECT DISTINCT city FROM events ) AS N,
events AS T
WHERE N.city = T.city
GROUP BY N.city
ORDER BY howmany
LIMIT 0,2