开发者

Update multiple columns in multiple rows in one sql statement?

This pseudocode (inaccurate SQL) shows what I want to do.

upd开发者_如何学运维ate tableA (colA, colB, colC, colD)
select b.colA, b.colB, c.colC, c.colD
from tableB b 
    left outer join tableC c 
       on b.id = c.id
    inner join tableA a 
       on c.myNum = a.myNum 
    inner join tableD 
        on a.newId = f.newId
where f.imported = 1

How can I do this in a syntactically correct fashion?


Something like this:

UPDATE TABLE 
SET ...
FROM Table1, Table2 ....
WHERE .....


update tableA 
 Set a.ColA = b.ColA,
     a.Colb = b.ColB,
     a.ColC = c.Colc,
     a.ColD = c.ColD
from tableB b 
 left outer join tableC c 
   on b.id = c.id
 inner join tableA a 
   on c.myNum = a.myNum 
 inner join tableD 
    on a.newId = f.newId
 where f.imported = 1


SQL> select *from Dewashish84;

E_ID E_NAME        E_EDUCATION
---------- ------------- ---------------

   100 dewa          MCA
   101 Raj           MSCIT
   145 mohan         BA
   103 ram           MTECH
     5 Sohan         BTECH

SQL>

update harshad set E_NAME= decode(E_EDUCATION,'MCA','dewa','MSCIT','Raj','BA','mohan',
     'MTECH','ram');

 5 rows updated.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜