Expression #39 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'imx365.a.aid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by SELECT t.*,a.aid AS img_aid,upload_datetime FROM article_topics AS t LEFT JOIN article_attachments AS a ON (t.id = a.topic_id) WHERE t.category_id IN (2, 3, 4, 5, 6, 7, 8, 9, 19, 28, 27, 26, 25, 24, 23, 22, 21, 20, 10, 18, 17, 16, 15, 14, 13, 12, 11, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49) GROUP BY id ORDER BY t.id LIMIT 0, 5