mysql - PHP Get the most popular item in table -


lets table looks like:

username userid a1       1 a1       1 a1       1 b2       2 c2       3 d2       3 

the popular username:a1

how find popular item in table?

select username, count(*) frequency your_table group username order frequency desc limit 1 

would yield single row:

username | frequency ---------+---------- a1         3 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -