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 b.id not in (4582,31,47,32,28508,33,257374,34,49,35,50,36,51,37,52,38,53,19,' at line 1