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 'fff2062.jpg = 1) AND tipo IN (23) 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_thumbc1e43268-5763-fc7a-3304-619e1fff2062.jpg = 1) AND tipo IN (23) AND provincia IN (460) order by escaparate desc, chalet-independiente-en-amplia-finca-en-venta-565000-euros-mentrida_thumbc1e43268-5763-fc7a-3304-619e1fff2062.jpg desc, tipo asc, fecha desc, id