update a set t=(select t from b where i=a.i), l=(select l from b where i=a.i), k=(select k from b where i=a.i) where exists (select 1 from b where i=a.i)
多谢楼上的答复,我的描述可能没说清楚: update a set a.t = a.t+b.t, a.l = a.l+b.l, a.k = a.k+b.k from a,b where a.i=b.i 需要想加之后把新的值写上去?
update a set t=t+(select t from b where i=a.i), l=l+(select l from b where i=a.i), k=k+(select k from b where i=a.i) where exists (select 1 from b where i=a.i)
merge into a using(select * from b) b on(a.i = b.i) when matched then update set a.t = a.t + b.t , a.l = a.l + b.l ,a.k = a.k + b.k
--2个表的update,用merge效率比较比传统的Update语句高 merge into a using b on (a.i=b.i) when matched then set a.t=a.t+b.t,a.l=a.l+b.l,a.k=a.k+b.k;
set t=(select t from b where i=a.i),
l=(select l from b where i=a.i),
k=(select k from b where i=a.i)
where exists (select 1 from b where i=a.i)
update a set a.t = a.t+b.t, a.l = a.l+b.l, a.k = a.k+b.k
from a,b
where a.i=b.i
需要想加之后把新的值写上去?
set t=t+(select t from b where i=a.i),
l=l+(select l from b where i=a.i),
k=k+(select k from b where i=a.i)
where exists (select 1 from b where i=a.i)
using(select * from b) b
on(a.i = b.i)
when matched then update set a.t = a.t + b.t , a.l = a.l + b.l ,a.k = a.k + b.k
merge into a
using b
on (a.i=b.i)
when matched then set a.t=a.t+b.t,a.l=a.l+b.l,a.k=a.k+b.k;