Expression #11 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'hirlevel.r.relid' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT f.*, r.relid, '' AS val, 0 AS dataid FROM `em_list_field` f, `em_list_field_rel` r WHERE f.id = r.fieldid AND r.relid IN (10, 55, 74, 14, 59, 43, 7, 8, 76, 23, 69, 38, 39, 67, 44, 58, 36, 40, 56, 52, 61, 64, 66, 33, 75, 34, 49, 47, 48, 15, 62, 53, 17, 9, 28, 73, 42, 19, 5, 68, 63, 57, 46, 3, 54, 27, 37, 41, 4, 11, 35, 72, 31, 50, 45, 2, 32, 70, 6, 60, 0) GROUP BY f.id ORDER BY r.dorder ASC