Query Error in 'CPSetSelection::execute' method in '/var/www/vhosts/consortia.com/httpdocs/class.cp_sets.php' on line 8635, You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY mainTable.cpda_seq, mainTable.cpda_id' at line 1

Full query: SELECT mainTable.* FROM cp_data AS mainTable LEFT OUTER JOIN cp_data AS table0 ON table0.cpda_meta_id = mainTable.cpda_id AND table0.cpda_meta_key = '1712' WHERE mainTable.cpda_meta_id = 1700 AND mainTable.cpda_meta_key = 'set_element_stub' AND mainTable.cpda_active = 1 AND table0.cpda_meta_val =  ORDER BY mainTable.cpda_seq, mainTable.cpda_id