Personal tools
You are here: Home Les outils logiciels SGBD Oracle sql - How to update a table from a another table
Log in


Forgot your password?
 

sql - How to update a table from a another table

 

 

UPDATE table_a a
   SET field_2 = ( SELECT field_2
                     FROM table_b b
                    WHERE b.id = a.id )
;

exemple :

/* update ref_sh_en_description for sh code 6 */
update ref_commodity_sh
set description = (
select substr(tmp_ref_sh_2022_nolevel.ref_sh_en_description, 1, 500)
from tmp_ref_sh_2022_nolevel
where tmp_ref_sh_2022_nolevel.ref_sh_code2= ref_commodity_sh.code
and tmp_ref_sh_2022_nolevel.ref_sh_level in (4,5)
)
where ref_commodity_sh.sh_type = 6
;

source :

https://dba.stackexchange.com/questions/3033/how-to-update-a-table-from-a-another-table

Document Actions
« April 2024 »
April
MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
2930