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 'c-16b0-561e31b2138c.jpg = 1) AND tipo IN (15) 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-adosado-en-alquiler-2250-euros-mensual-las-rozas-de-madrid-zona-burgo-parque-paris_7a7dfc39-fe80-0e3c-16b0-561e31b2138c.jpg = 1) AND tipo IN (15) AND provincia IN (460) order by escaparate desc, chalet-adosado-en-alquiler-2250-euros-mensual-las-rozas-de-madrid-zona-burgo-parque-paris_7a7dfc39-fe80-0e3c-16b0-561e31b2138c.jpg desc, tipo asc, fecha desc, id