当前位置 博文首页 > iloki的博客:oracle update
--更新高价件表中的型号, hm_material h1
update hm_highrate_material h
set h.material_model = (select h1.model from hm_material h1
where h.material_id = h1.material_id);
--对表A的a2,a3进行更新(带条件);
update A
set (A.a2, A.a3) =
(select B.b2, b.b3
from B
where B.b1 = A.a1 and A.a3 = 100)
where exists (select 'X'
from B
where B.b1 = A.a1 and A.a3 = 100);
--或者:
update A
set (A.a2, A.a3) =
(select B.b2, b.b3
from B
where B.b1 = A.a1 and A.a3 = 100)
where A.a1 in (select B.b1
from B
where B.b1 = A.a1 and A.a3 = 100);
cs