PDA

View Full Version : Query most common result for a field


rswyatt
11-11-2005, 04:23 PM
I have a table that has a field called "content"..

I want to write a query ( so that I don't have to go through all kinds of PHP script ) that will return to me the data result that occurs the most for that field...

So - if in the content field I have the following results:

entryid content
1 bob
2 bob
3 bob
4 rick
5 rick
6 bob


I want the query to give me bob.

Does that make sense? Is it possible?

hyperbole
11-12-2005, 05:14 PM
SELECT content, Count(content) AS count
FROM table
GROUP BY content
ORDER BY count DESC
LIMIT 1