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 4 SELECT p.*,c.* from n_compras p INNER JOIN n_fornecedores c ON (p.id_fornecedores = c.id_fornecedores) WHERE p.id_compras =