MyBB Community Forums

Full Version: Query to show posts with most reputations
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
can some please help me what query i should use to show posts with most reputation points?
call a table for reputations and add order by reputation DESC LIMIT x

So you have the limit to the threads you wanna show, and order by rep DESC you told more to minus rep, cheers, hope it helps.
can you please post the query cos it is complicated for me.
Something like this:
SELECT r.pid, p.uid, p.subject, p.message, p.username, COUNT(*) as count
FROM mybb_reputation r
LEFT JOIN mybb_posts p ON (r.pid=p.pid)
GROUP BY r.pid
ORDER BY count DESC
LIMIT 5
thank you. this will get all posts with reputations? How can i get all posts with negative reputations? what query do i need. thank you again
It should select 5 uid/username/subject/message from posts with the most positive/negative/neutral (so overall) reputations. Change 5 to higher value if you want more.

For negative only, this would work I guess:
SELECT r.pid, p.uid, p.subject, p.message, p.username, COUNT(*) as count
FROM mybb_reputation r
LEFT JOIN mybb_posts p ON (r.pid=p.pid)
WHERE r.reputation < 0
GROUP BY r.pid
ORDER BY count DESC