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 pi.product_id = addi.additionalproduct_id AND pi.product_i' at line 60