Код: Выделить всё
SELECT
distinct blog.*,
(
select
count(blog_id)
from
blog_comment
where
blog_comment.blog_id = blog.id
) as comment
FROM
blog
Left JOIN
blog_comment
ON blog.id = blog_comment.blog_id
Подробнее здесь: https://stackoverflow.com/questions/226 ... -codeignit