I have a mistake in this sql statement and I don’t know why:
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;
The mistake is:
Err] 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 ‘.ip_custom_pvp) as c_ip_pvp, ‘ at line 32
Line 32 is marked with ==>.
Could you help me?. Thanks so much
Are you sure you shouldn’t have some other characters in there, like a
+or-sign for example?It seems to me that that’s three separate columns:
which should be joined in some other manner than just removing the white space between them 🙂
That’s not the only occurrence by the way, just the first one I picked up on. There’s one on the following line as well.
The reason MySQL is complaining is that you’re apparently breaking the
schema.objectnaming standard by having two.characters in the fill object name (hence three rather than two levels).