我這里說的,用left join update數據的是指
有a,b兩表,將b表數據根據某個歸則關聯更新到a表.
Oracle.寫法1 目前用得最多的, 注意: 當b表沒有對應數據時, a表 xxx欄位會更新為null
update a set a.xxx = (select b.eee from b where a.bid = b.id)
Update emp
Set(sal,comm) = (select sal,comm. From emp1 where emp.empno = emp1.empno)
Oracle.寫法2 用merge
merge into a
using b
on (a.a=b.b)
when matched then update set xxxxx
when not matched then insert (xxx) values(xxx);
其它寫法,Oracle 不支持
update a set a.xxx=b.eee
from a
left join b on a.bid=b.id
阿飛
2015/04/28
阅读(4398) | 评论(0) | 转发(0) |