ERROR: 1064-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 'and ugx.groupid IN (SELECT groupid FROM univ_inst_groups_xref where instuid = )' at line 1 SQL: SELECT concat("/dynamic/school/?instuid=", ui.instuid) as value, substring(ui.`name`,locate('-',ui.`name`)+1) as label, ui.`param00` FROM univ_inst_groups ug JOIN univ_inst_groups_xref ugx on ugx.groupid = ug.id JOIN univ_institutes ui on ui.instuid = ugx.instuid where ui.instuid <> and ugx.groupid IN (SELECT groupid FROM univ_inst_groups_xref where instuid = )