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 'e-0537-65b2b0ce7624.jpg = 1) AND tipo IN (21) 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 (atico-en-venta-340000-euros-las-rozas-de-madrid-zona-yucatan-la-cornisa_thumb752bd5a3-160e-217e-0537-65b2b0ce7624.jpg = 1) AND tipo IN (21) AND provincia IN (460) order by escaparate desc, atico-en-venta-340000-euros-las-rozas-de-madrid-zona-yucatan-la-cornisa_thumb752bd5a3-160e-217e-0537-65b2b0ce7624.jpg desc, tipo asc, fecha desc, id