SELECT DISTINCT m.id, concat(m.manufacturer,' ',m.model) as name FROM mobiles as m, handsets_datafiletypes as h, datafiletypes as d WHERE h.handset_id = m.id AND h.datafiletype_id = d.id AND d.subtype_id = '' AND h.datafiletype_id IN () ORDER BY name You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY name' at line 15