SELECT `a`.*, `cat`.* , COUNT(`c`.`id`) `comments_count` FROM `articles` `a` LEFT JOIN `category` `cat` ON(`a`.`a_cat` = `cat`.`id`) LEFT JOIN `comments` `c` ON(`c`.`article_id` = `a`.`id`) WHERE `a`.`it_visible` = 1 GROUP BY `a`.`id`