稍微麻烦些update tmp2 a
set (m,num) = 
        (select a.m+b.m, a.num+b.num)
           from tmp3 b
            where a.operid=b.operid and a.msort=b.msort)
where (a.a.operid a.msort) in
     (select c.operid,c.msort from tmp3 c)
;

解决方案 »

  1.   

    update tmp2
    set b.m=a.m+b.m, b.num=a.num-b.num
    from tmp2 a, tmp3 b
    where a.operid=b.operid and a.msort=b.msort
      

  2.   

    如果觉得有麻烦的话,可以更新两次。oracle 为什么不支持这样的语法啊?奇怪?
      

  3.   

    有重复行的话会出错,使用distinct
      

  4.   

    有重复的话就是你的数据库设计和你的程序有冲突!distinct也没用
      

  5.   

    update tmp2 a set (m,num)=(select max(a.m+b.m),max(a.num-b.num) from tmp3 b where operid=a.operid and msort=a.operid)
      

  6.   

    重复行好像报:
    subquery ..more than sigle row....哈哈,遇见的太多了,都记住了