我正在使用MyBB,我想在我的网站主页上显示拥有最多读者当前的主题。
我假设我必须查询会话表,但我不确定应该怎么做
我需要的mysql结果应该类似于:
-------------------------
|title | count |
-------------------------
|thread a title | 1234 |
|thread b title | 913 |
|thread c title | 678 |
|another title | 593 |
|different title| 550 |
-------------------------
谢谢:)
答案 0 :(得分:4)
我刚刚在我的主板上测试过,我认为这就是你所需要的:
SELECT COUNT(*) as count, subject as title
FROM `mybb_sessions`,`mybb_threads`
WHERE location1 = tid
GROUP BY `location1`
ORDER BY COUNT(*) DESC
LIMIT 10