On a site I am developing I have a simple user system and their details are stored in a MySQL database table called 'user'. Similarily I have both articles and tutorial which are stored in the tables 'articles' and 'tutorials'. In both the article and tutorial tables there is the userID foreign key which links it to its author held in the user table. What I want to do is to perform a query and return the 5 most active users. Basically the more articles/tutorials they have written the more active they are considered to be. So if user 'Bob' has written 2 tutorials and 3 articles then he has an activity level of 5. User 'Jill' however has written 10 articles and 0 tutorials and is therefore more active than 'Bob' with 10. Any help would be much appreciated. Thanks
You can write a query this way Select user then use count articles from article table then count tutorials from tutorials table group by user and if you want only top 5 then you can use sorting and limit. Work on this query and you will get your answer. Regards, Gonzo