Expression #11 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'boss33co_help.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 `hd_ticket_field` f, `hd_ticket_field_rel` r WHERE f.id = r.fieldid AND r.relid IN (1, 0) GROUP BY f.id ORDER BY r.dorder ASC