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 'f-8884-5bd2f49ef2e2.jpg = 1) AND tipo IN (17) AND provincia IN (460) order by ' at line 1 Error en buscarLibre. Consulta: select * from m_inmuebles where terminado=1 and estadoOp='Activo' and visible_web=1 AND (chalet-independiente-en-venta-3000000-euros-fresnedillas-de-la-oliva_thumb4ce21403-1cec-8e8f-8884-5bd2f49ef2e2.jpg = 1) AND tipo IN (17) AND provincia IN (460) order by escaparate desc, chalet-independiente-en-venta-3000000-euros-fresnedillas-de-la-oliva_thumb4ce21403-1cec-8e8f-8884-5bd2f49ef2e2.jpg desc, tipo asc, fecha desc, id