create table aa(a number, b number, c number)
create table bb(a number, b number, c number)aa
a b c
1 0 0
2 0 0
3 0 0
bb
a b c
1 1 1
2 2 2
3 3 3
4 4 4
现在要根据aa中的a字段和bb中的a字段来更新aa的数据,得到
a b c
1 1 1
2 2 2
3 3 3我想到了这种方法,但是不好,重复了
update aa ta set ta.b = (select b from bb where ta.a = a),ta.c = (select c from bb where ta.a = a)大家帮忙看看
update aa
set (a,b,c)
=(select a,b,c from bb where bb.a=aa.a)
where exists (select a,b,c from bb where bb.a=aa.a)
set (ta.b, ta.c) = (select b, c from bb where ta.a = a)
where exists (select 1 from bb where ta.a = a);
update
select aa.b b1, aa.c c1, bb.b b2, bb.c c2
from aa, bb
where aa.a = bb.a
set
(
b1 = b2,
c1 = c2
)
;
update aa
set
aa.b = bb.b,
aa.c = bb.c
from bb
where aa.a = bb.a