Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'virgin_pretty.pc.comment_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by -> SELECT pa.pic_id, pa.pic_thumbnail, pa.pic_title, pa.pic_user_id FROM phpbb_album as pa LEFT JOIN phpbb_users AS u ON pa.pic_user_id = u.user_id LEFT JOIN phpbb_album_comment as pc ON pa.pic_id = pc.comment_pic_id WHERE pa.pic_user_id <> 0 AND pa.pic_cat_id <> 2 AND pa.pic_cat_id <> 999999 AND u.user_regdate < 1544528549 GROUP BY pa.pic_id ORDER BY pc.comment_id desc limit 0, 4