MySQL i: (1064) 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 'AND NOT IN (SELECT DISTINCT id_oferta FROM ' at line 12 sql:SELECT, d.nombre, d.permalink FROM bookingfax.destinos d LEFT JOIN bookingfax.ofertas_destinos od ON = od.id_destino LEFT JOIN bookingfax.ofertas o ON = od.id_oferta LEFT JOIN bookingfax.ofertas_categorias oc ON = oc.id_oferta LEFT JOIN bookingfax.categorias c ON = oc.id_categoria WHERE 1 AND != 4 AND != 7 AND o.pvp != "" AND o.multidistribucion=1 AND o.caducidad > curdate() AND d.id_padre = AND NOT IN (SELECT DISTINCT id_oferta FROM bookingfax.ofertas_categorias WHERE id_categoria = 4 OR id_categoria = 7) AND o.marca IN (SELECT id_proveedor FROM bookingfax.bookingfax_proveedores_por_grupo WHERE id_grupo = 50) GROUP BY d.nombre ORDER BY nombre ASC