-2

我在这个 sql 语句中有一个错误,我不知道为什么:

SELECT t1.id_servidor_virtual as id_servidor_virtual,
    t1.nombre_servidor as nombre_servidor, 
    t1.plantilla as plantilla, 
    (SELECT tt1.descripcion
        FROM sku_precios tt1
        WHERE tt1.id_sku_precio = 'VM --') as c_sv,
    t1.sv_pvp as c_sv_pvp,
    t1.sv_pvp_dist as c_sv_pvp_dist,
    (SELECT tt1.descripcion
        FROM sku_precios tt1
        WHERE tt1.id_sku_precio = 'VCPU --') as c_cpu,
    t1.cpu_cant as c_cpu_cant,
    t1.cpu_pvp as c_cpu_pvp,
    t1.cpu_pvp_dist as c_cpu_pvp_dist,
    (SELECT tt1.descripcion
        FROM sku_precios tt1
        WHERE tt1.id_sku_precio = 'RAM --') as c_ram,
    t1.ram_cant as c_ram_cant,
    t1.ram_pvp as c_ram_pvp,
    t1.ram_pvp_dist as c_ram_pvp_dist,
    aletras(t1.ram_cant) as c_ram_unidad,
    (SELECT tt1.descripcion
        FROM sku_precios tt1 
        WHERE tt1.id_sku_precio = 'HDSTD --') as c_hdd,
    t1.hdd_cant as c_hdd_cant,
    t1.hdd_pvp as c_hdd_pvp,
    t1.hdd_pvp_dist as c_hdd_pvp_dist,
    aletras(t1.hdd_cant) as c_hdd_unidad,
    (SELECT tt1.descripcion
        FROM sku_precios tt1
        WHERE tt1.id_sku_precio = 'IPP --') as c_ip,
==> (t1.ip_pvpt1.ip_polled_pvpt1.ip_custom_pvp) as c_ip_pvp, 
    (t1.ip_pvp_distt1.ip_polled_pvp_distt1.ip_custom_pvp_dist) as c_ip_pvp_dist, 
    t1.id_servidor_virtual as parent_id, 
    (SELECT COUNT(t2.id_servicio_adicional) 
        FROM servicios_adicionales t2 
        WHERE t2.id_servidor_virtual = t1.id_servidor_virtual) as cant_sa,
    DATE_FORMAT(t2.f_inicio_contrato, '%d-%m-%Y') as f_inicio_contrato, 
    DATE_FORMAT(t2.f_fin_contrato, '%d-%m-%Y') as f_fin_contrato, 
    (SELECT tt2.n_pedido 
        FROM servidores_virtuales tt1 
        INNER JOIN pedidos tt2 ON tt2.id_pedido = tt1.id_pedido 
        WHERE tt1.id_servidor_virtual = t2.id_pedido_actualizado) as n_pedido_actualizado, 
    (SELECT t3.descuento 
        FROM albaranes t3 
        WHERE t3.id_pedido = t1.id_pedido 
        AND t3.id_cuenta_emisora = 2) as descuento 
FROM servidores_virtuales t1 
LEFT OUTER JOIN pedidos t2 ON t2.id_pedido = t1.id_pedido 
WHERE t1.id_pedido = 230;

错误是:

Err] 1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 32 行的 '.ip_custom_pvp) as c_ip_pvp, ' 附近使用正确的语法

第 32 行标有==>

你可以帮帮我吗?。非常感谢

4

1 回答 1

1
t1.ip_pvpt1.ip_polled_pvpt1.ip_custom_pvp

你确定你不应该在那里有一些其他的字符,比如一个+-标志吗?

在我看来,这是三个独立的列:

t1.ip_pvp   t1.ip_polled_pvp   t1.ip_custom_pvp

应该以其他方式加入,而不仅仅是删除它们之间的空白:-)

顺便说一句,这不是唯一的事件,只是我捡到的第一个。下一行也有一个。

MySQL 抱怨的原因是您显然违反了schema.object命名标准,因为填充对象名称中有两个 .字符(因此是三个而不是两个级别)。

于 2012-10-25T09:22:00.543 回答