update a set a.t+b.t, a.l+b.l, a.k+b.k
from a,b
where a.i=b.i
转为oralce 的update语句,怎么写,请高手指教.

解决方案 »

  1.   

    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)
      

  2.   

    多谢楼上的答复,我的描述可能没说清楚:
    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 
    需要想加之后把新的值写上去?
      

  3.   

    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)
      

  4.   

    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
      

  5.   

    --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;