Update with a from [closed]

0

I'd like to know what I'm doing wrong in my SQL query

update 
   tabla_c
set 
   tabla_c.precio = tabla_c.precio *    talba_b.porcentaje
FROM
   cat_marca as tabla_c inner join cat_concepto as tabla_a on   tabla_c.id_concepto = tabla_a.id_concepto
inner join cat_depreciacion as tabla_b on tabla_a.id_depreciacion =  tabla_b.id
Where
   tabla_c.nombre_marca = neffos
    
asked by emmanuel gomez toledo 16.11.2018 в 19:02
source

1 answer

0

In SQL the UPDATE statement is used to update the data of a single table, so it does not support the "JOIN" with other tables, at least not in a natural way

The standard ANSI syntax is:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

I think, the reformulation of the sentence should be:

UPDATE cat_marca as tabla_c
   SET tabla_c.precio = (SELECT tabla_c.precio * tabla_b.porcentaje
                         FROM   cat_concepto as tabla_a
                         INNER  JOIN cat_depreciacion as tabla_b 
                                  ON tabla_a.id_depreciacion =  tabla_b.id
                         WHERE   tabla_c.id_concepto = tabla_a.id_concepto)
WHERE  tabla_c.nombre_marca = neffos
    
answered by 16.11.2018 / 19:35
source