Selecting the value that appears most often in a column?

I have a table…

id | tid | uid | priority | status

…and would like to query it on the uid column to retrieve the uid that appears most frequently in that column. The table is indexed on uid.

The table size may become immense, so overSELECTing data and figuring it out in PHP will be too pricey. :slight_smile:

What’s the speedy way to get this done?

Thanks,

Cranjled

I should add… this is what I’ve tweaked the query down to… good approach or?


SELECT myField, count(*)
AS totalRecords
FROM table
GROUP BY myField
ORDER BY totalRecords 
DESC 
LIMIT 1;