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

Glib GIOChannel -

delphi - When I encode/decode SMS PDU (GSM 7 Bit) user data, do I need prepend the UDH first? -

python - Obscure curses error message when creating a sub window -