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 'f80105e.jpg = 1) AND tipo IN (17) 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 (chalet-independiente-en-amplia-finca-en-venta-565000-euros-mentrida_4266a884-677b-f69b-f701-619e1f80105e.jpg = 1) AND tipo IN (17) AND provincia IN (460) order by escaparate desc, chalet-independiente-en-amplia-finca-en-venta-565000-euros-mentrida_4266a884-677b-f69b-f701-619e1f80105e.jpg desc, tipo asc, fecha desc, id