Hi, I have a posts table, which has a number of fields, including a user id field.
What I would like to do is find out which user has the most entries in the table.
I am using Mysql and PHP. Could you help me write the query?
Thanks.
try this: SELECT COUNT(id) AS total_posts FROM table GROUP BY user ORDER BY total_posts DESC LIMIT 1;
doesn't 'user' also have to be in the column list?
yes, along with anything else from the table that would be nice to show the user. the question wasn't how to pull users from the table, but how to select the highest postcount. i figure decius is smart enough to modify the example query as necessary.