这个伪代码(不准确的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
我怎样才能以语法正确的方式做到这一点?
答案 0 :(得分:2)
这样的事情:
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
答案 1 :(得分:0)
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.