Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'imx365.img.aid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by SELECT,a.userid,a.title,a.amount,img.aid AS img_aid,img.upload_datetime AS img_upload_datetime,img.ext AS ext FROM album_albums AS a LEFT JOIN album_inalbum AS i ON = i.album_id LEFT JOIN album_images AS img ON i.image_id = WHERE a.userid = 153254 GROUP BY ORDER BY DESC