SELECT news.*, menu.url AS url, COUNT(*) as tags_count FROM `news` LEFT JOIN menu ON news.id_menu = menu.id LEFT JOIN news_tags ON news_tags.news_id = news.id WHERE news.`visible` = 1 AND news.`id` IN ( SELECT `news_get` FROM `news_related` WHERE `news_see` = 88484 ) AND news_tags.tags_id IN () GROUP BY news.id ORDER BY tags_count DESC, news.datetime DESC Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') GROUP BY news.id ORDER BY tags_count DESC, n' at line 13