21,886
社区成员
发帖
与我相关
我的任务
分享
SELECT
c.content_id, c.title, c.readcount, c.contenttime,
u.user_name,
COUNT(r.reply_id) AS responses, IF(MAX(r.reply_time) is NULL,c.contenttime,MAX(r.reply_time)) AS last
FROM
content AS c
LEFT JOIN
reply AS r
USING
(content_id)
INNER JOIN
users AS u
ON
c.user_id = u.user_id
WHERE
c.nav_id = {$_SESSION['nav_id']}
GROUP BY
(r.content_id)
ORDER BY
last DESC