Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'hirlevel.r.dorder' 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 = r.fieldid AND r.relid IN (2) GROUP BY ORDER BY r.dorder ASC