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, 131, 47, 48, 3, 4) GROUP BY f.id ORDER BY r.dorder ASC