[英]Update multiple columns in multiple rows in one sql statement?
此偽代碼(不正確的SQL)顯示了我要執行的操作。
update 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
如何以句法正確的方式做到這一點?
像這樣的東西:
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.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.