3表链接,数据获取不全
数据表如下在获取栏目id是4的情况下有一条数据不显示(下图框住的数据)
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
你Groupby的值有重复的吗?我怎么记得groupby会合并相同的值,然后合并成一条数据
页:
[1]