即时通讯使用while循环显示我最新的论坛主题并计算一些字段
我正在尝试在一个查询中执行此操作,这是我的代码:
SELECT t.*,p.*,
SUM(t.topic_approved='1') AS Amount_Of_Topics,
SUM(t.topic_views) AS Amount_Of_Topic_Views,
SUM(t.topic_replies) AS Amount_Of_Topic_Replies,
SUM(p.post_approved ='1') AS Amount_Of_Posts
FROM bb3topics t left join bb3posts p ON t.topic_id=p.topic_id
ORDER BY t.topic_last_post_id DESC LIMIT 10
问题:
此代码仅显示一个论坛主题,而不是其他
我的查询代码有什么问题吗?!
答案 0 :(得分:3)
是
SUM总是与GROUP BY子句一起使用
答案 1 :(得分:1)
是的,你遗失了GROUP BY
。