我有这样的查询:
SELECT
b.title,
b.url,
b.`date`,
b.gallery,
count(c.id) as comments_count,
a.name,
b.content,
b.comments,
LEFT(b.content, LOCATE('<page>', b.content)-1) as content_short
FROM blog b
LEFT JOIN blog_comments c ON
(b.id = c.note AND c.approved = 1)
LEFT JOIN administrators a ON
(b.aid = a.id)
WHERE
b.`date` < now() AND
b.active = 1
ORDER BY b.`date` DESC;
现在,当我删除时count(c.id) as comments_count,
,我返回了 2 行。当它存在时,只返回 1 行。
有什么方法可以解决 ot 或者我只需要更改
count(c.id) as comments_count,
为(select count(id) as
comments_countfrom blog_comments where note = b.id) as comments_count,
吗?