내가있어 쿼리처럼 :카운트는 1 행의 반환을 원인
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가 아니면 단순히 (select count(id) as
comments_count from blog_comments where note = b.id) as comments_count,
에 count(c.id) as comments_count,
을 변경해야?
그리고 당신의 데이터 구조입니다
할 필드에 의한
Group by
를 추가해야합니까? – hims056