ORACLE : UPDATE DATA IN ONE TABLE WITH DATA FROM ANOTHER TABLE

Oracle¬†: Update data in one table with data from another tablE ( mise a jour d’un champs a partir d’une autre table sur Oracle )

Example :Update data in one table with data from another table

1-
UPDATE TABLEA
SET (b, c, d) = (SELECT b1, c1, d1 from TABLEB WHERE TABLEB.a1 = TABLEA.a and TABLEB.e1 > 40)
WHERE EXISTS (SELECT 1 from TABLEB WHERE TABLEB.a1 = TABLEA.a and TABLEB.e1 > 40)
/

2-
update table1
set table1.fk_cd_insee =
( select table2.fk_cd_insee
from table1, table2
where table1.key_primary=table2.key_primary
and table2.match=1
)
where table1.fk_cd_insee=’-1′

Leave a Reply