我在这个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;
错误是:
错误] 1064 - 您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以便在“.ip_custom_pvp”附近使用正确的语法作为c_ip_pvp,在第32行
第32行标有==>
。
答案 0 :(得分:1)
t1.ip_pvpt1.ip_polled_pvpt1.ip_custom_pvp
您确定不应该在其中包含其他字符,例如+
或-
符号吗?
在我看来,这是三个单独的列:
t1.ip_pvp t1.ip_polled_pvp t1.ip_custom_pvp
应该以其他方式连接,而不仅仅是删除它们之间的空白区域: - )
顺便说一下,这不是唯一一次,只是我接受的第一次。以下一行中也有一个。
MySQL抱怨的原因是,您显然在填充对象名称中包含两个 schema.object
个字符时违反.
命名标准(因此三个而不是两个水平)。