You have an error in your SQL syntax near 'AND t1.spactive = "T" ORDER BY t1.splastname DESC, t1.speakerid DESC LIM' at line 11SELECT t1.speakerid, t2.topicid FROM speakers t1, speakertopics t2 WHERE t1.speakerid = t2.speakerid AND ( (STRCMP(t1.splastname, "Apache Bow") = 0 AND t1.speakerid <118 ) OR STRCMP(t1.splastname, "Apache Bow")< 0 ) AND t2.topicid = AND t1.spactive = "T" ORDER BY t1.splastname DESC, t1.speakerid DESC LIMIT 1