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 'f51b9b.jpg = 1) AND tipo IN (23) AND provincia IN (460) order by escaparate de' at line 1 Error en buscarLibre. Consulta: select * from m_inmuebles where terminado=1 and estadoOp='Activo' and visible_web=1 AND (finca-rustica-en-venta-78000-euros-las-rozas-de-madrid-zona-marazuela-el-torreon_thumbd035950a-c907-ed9d-263a-6380e2f51b9b.jpg = 1) AND tipo IN (23) AND provincia IN (460) order by escaparate desc, finca-rustica-en-venta-78000-euros-las-rozas-de-madrid-zona-marazuela-el-torreon_thumbd035950a-c907-ed9d-263a-6380e2f51b9b.jpg desc, tipo asc, fecha desc, id