kalster Posted May 29, 2015 Share Posted May 29, 2015 I have a mysql table like the following. post | username ______________ post1 | username1 post2 | username2 post3 | username1 I need a mysql count or max query that would get the highest post count of a user. At the table above, the post count would be 2 because username1 posted two times. Both the post and username data are unknown. Quote Link to comment Share on other sites More sharing options...
PravinS Posted May 29, 2015 Share Posted May 29, 2015 Try this query SELECT username, count(username) AS post_count FROM TABLE_NAME GROUP BY username ORDER BY count(username) DESC; you can apply LIMIT to get top records, as query will give sorted result according to max post count of user. Quote Link to comment Share on other sites More sharing options...
kalster Posted May 29, 2015 Author Share Posted May 29, 2015 That gives me the user with the highest post count. What i need is the post count of the user that posted the most. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.