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 'jpg = 1) AND tipo IN (21, 25, 22, 26, 14, 2, 24) AND provincia IN (460) order ' at line 1 Error en buscarLibre. Consulta: select * from m_inmuebles where terminado=1 and estadoOp='Activo' and visible_web=1 AND (_9e7f2184-19c9-eb04-5f55-631720550974.jpg = 1) AND tipo IN (21, 25, 22, 26, 14, 2, 24) AND provincia IN (460) order by escaparate desc, _9e7f2184-19c9-eb04-5f55-631720550974.jpg desc, tipo asc, fecha desc, id