Click to See Complete Forum and Search --> : find who has most entries


Palli
10-06-2008, 10:53 AM
I have a database of 300,000 entries. All have an id field. I want to find out who has the most entries in the database.... is this possible. I can't seem to find anything online.

I have tried

SELECT COUNT(id)
FROM myTable

legendx
10-06-2008, 11:03 AM
SELECT user_id, count(id) as total FROM myTable GROUP BY user_id ORDER BY total DESC


Add a LIMIT or TOP, depending on your database, to only retrieve the user with the most records.

Palli
10-06-2008, 11:21 AM
perfect thanks :):):):)