Have an account? Sign in
Login  Register  Facebook
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
Started: September 15, 2011 Latest Activity: September 15, 2011 mysql select join
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
In: September 15, 2011

thank you!! it worked fine.
September 15, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer