![]() |
SQL Query Question
I'm just wondering on an sql query let's say I have a userid column on a particular table and I want to see which userid is repeated the most throughout the table, what kind of mysql command would I need to enter to list in DESC order from the most entrees of a userid column to the list.
So if I had let's say 5 table entrees. 3 of them where for userid 2, one of them was for userid 1 and the other was for userid 3, It'd list the three tables with userid 2 firstm then userid 1 then userid 2. Then next question is how would I write a mysql_num_rows statement to just quickly fetch the total number of entrees by whoever has the largest entree number in a particular table which in this case would be userid 2 with 3 entrees. |
[SQL]SELECT COUNT(*) AS counter, userid
FROM table GROUP BY userid ORDER BY counter DESC[/sql] and add a limit 1, if you want just the top user ;) |
All times are GMT. The time now is 07:07 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|