how i can select the top users from the database
i have a \'forum_posts\' table and \'forum_useres\' table now i want:
select from \'forum_posts\' the users that have the top number of posts from \'forum_posts\' tables structure \'forum_posts\' post_id | user_id | post_date \'forum_useres\' user_id | user_name but i want select the posts from just one day this mean i want today top users
1 Answer
maybe something like this:
SELECT COUNT(1) cnt, a.user_id FROM `forum_posts` a LEFT JOIN `forum_useres` u ON a.user_id = u.user_id WHERE from_unixtime(post_date) >= SUBDATE(NOW(),1) GROUP BY a.user_id ORDER BY cnt DESC LIMIT 0 ,10 Posted: MacOS 2 of 2 people found this answer helpful. Did you? Yes No thank you!! it worked fine. |
© Advanced Web Core. All rights reserved