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 c.stt=1 ORDER BY c.position' at line 1 in SELECT c.caracteristica FROM nf_sitio_caracteristica c INNER JOIN nf_sitio_nf_sitio_caracteristica r ON c.id = r.nf_sitio_caracteristica_id AND r.nf_sitio_id = AND c.stt=1 ORDER BY c.position