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 'f410d.jpg = 1) AND tipo IN (23) AND provincia IN (460) order by escaparate des' 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-amplia-finca-en-venta-565000-euros-mentrida_thumb686d4509-17cf-9a4e-d626-619e203f410d.jpg = 1) AND tipo IN (23) AND provincia IN (460) order by escaparate desc, chalet-independiente-en-amplia-finca-en-venta-565000-euros-mentrida_thumb686d4509-17cf-9a4e-d626-619e203f410d.jpg desc, tipo asc, fecha desc, id