I have a table with a int field of which I want the most frequent value. If rows contain the values, 8, 4, 8, 2, 9, the query I'm searching for would return 8. My current solution is to go through all records, and count the frequency of the values using PHP. I hope there is a better solution, something like:
select * from table1 order by frequency(row1) desc