I'm trying to run a query to see who's asked the most questions. The user information is in a separate table to the question information. I can run a MySQL query in phpMyAdmin which provides the groups - IE, one person has asked X amount of questions, another user has asked Y amount of questions - you get my gist?
This SQL code is simple: SELECT COUNT( * ) FROM polls GROUP BY polls.poll_author LIMIT 5; which does half of what I want to do. When I try a SQL code which I thought would work, I was disappointed and tried many methods to work around it. I tried SELECT COUNT( * ) FROM polls, users GROUP BY polls.poll_author LIMIT 5; but that only returned the "COUNT" field - not the user ID which is essentially what I want so I can differentiate who posted X amount of polls.
Also, when I try a SQL code without the COUNT function, like so SELECT * FROM polls, users GROUP BY polls.poll_author; it just shows me the users and their first question - not the amount of rows they have of questions.
I hope someone can help me out - this is bugging me a little />/>/>/>
Many thanks, always appreciated.
My MySQL Query should have been SELECT COUNT(polls.poll_author), users.user_id FROM users, polls WHERE users.user_id=polls.poll_author GROUP BY users.user_id;
This post has been edited by huzi8t9: 30 November 2012 - 12:52 PM