SELECT `a`.*, COUNT(`c`.`id`) `comments_count` FROM `articles` `a` LEFT JOIN `comments` `c` ON(`c`.`article_id` = `a`.`id`) GROUP BY `a`.`id`