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 (l.mls_id IN (1,433,446,448,510)) AND (l.gps_show is null or l.gps_show =' at line 2