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
Post a Comment