Oracle SQL: Update a table with data from another table

后端 未结 7 2138
广开言路
广开言路 2020-11-22 02:01

Table 1:

id    name    desc
-----------------------
1     a       abc
2     b       def
3     c       adf

Table 2:

id    na         


        
7条回答
  •  灰色年华
    2020-11-22 02:17

    BEGIN
    For i in (select id, name, desc from table2) 
    LOOP
    Update table1 set name = i.name, desc = i.desc where id = i.id and (name is null or desc is null);
    END LOOP;
    END;
    

提交回复
热议问题