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 o.pvp != "" AND o.caducidad >= curdate() GROUP BY o.titulo ' at line 16 sql:SELECT date_format(o.primera_salida,"%d/%m/%Y") primera, date_format(o.ultima_salida,"%d/%m/%Y") ultima, o.titulo titulo, o.url, d.nombre destino, m.nombre proveedor, id_oferta, o.pvp, o.permalink FROM bookingfax.ofertas o INNER JOIN bookingfax.ofertas_destinos od ON = od.id_oferta INNER JOIN bookingfax.destinos d ON od.id_destino = INNER JOIN bookingfax.ofertas_categorias oc ON oc.id_oferta = INNER JOIN bookingfax.marcas m ON o.marca = WHERE 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 = 3) AND o.multidistribucion=1 AND = AND o.pvp != "" AND o.caducidad >= curdate() GROUP BY o.titulo ORDER BY primera, proveedor