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 '' at line 3 SQL query : SELECT p.producerID as id, p.name as name, p.link_name as link_name FROM ss_producers p, ss_category_producer cp where p.producerID = cp.producerID and cp.categoryID =