mysqlsqlforummybb

I'm using mybb, how can I find the top 5 threads that has the most readers currently?


I'm using MyBB, I want to show on my website homepage the threads that has the most readers currently.

I'm assuming I have to query the session table but I'm not sure how should I do it

The mysql result I need, should look something like:

-------------------------
|title          | count |
-------------------------
|thread a title | 1234  |
|thread b title | 913   |
|thread c title | 678   |
|another  title | 593   |
|different title| 550   |
-------------------------

Thank you :)


Solution

  • I've just tested that on my board, I think this is what you need:

    SELECT COUNT(*) as count, subject as title
    FROM `mybb_sessions`,`mybb_threads`
    WHERE location1 = tid
    GROUP BY `location1`
    ORDER BY COUNT(*) DESC
    LIMIT 10