Results 1 to 2 of 2
May 9, 2010, 16:33 #1
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.
What's the speedy way to get this done?
May 9, 2010, 17:17 #2
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;