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 'ca8eefa3.jpg = 1) AND tipo IN (7) AND provincia IN (460) order by escaparate d' at line 1 Error en buscarLibre. Consulta: select * from m_inmuebles where terminado=1 and estadoOp='Activo' and visible_web=1 AND (garaje-en-venta-10000-euros-las-rozas-de-madrid_thumba2290cc0-5e50-2494-dd38-51e3ca8eefa3.jpg = 1) AND tipo IN (7) AND provincia IN (460) order by escaparate desc, garaje-en-venta-10000-euros-las-rozas-de-madrid_thumba2290cc0-5e50-2494-dd38-51e3ca8eefa3.jpg desc, tipo asc, fecha desc, id