update b
set volume_b=
(select volume_a from a,b where a.id=b.id)
where exist(select 1 from a,b where a.id=b.id);

解决方案 »

  1.   

    不对!!!
    我不是更新一条记录.是需要把两个表每个id相等的volume_a匹配到volume_b.
    有很多记录!上面返回的错误是:单行子查询返回多于一个行
      

  2.   

    加个max或min
    update b
    set volume_b=
    (select max(volume_a) from a where a.id=b.id group by a.id)
    where exist(select 1 from a where a.id=b.id);
      

  3.   

    需要游标吗?
    怎么现在没有sql高手啊
      

  4.   

    jiezhi(Niu)给的那个语句就是成批修改的呀,你试试看再说
      

  5.   

    要保证a.id唯一,不然语句肯定错误语
    begin
    update b
    set volume_b=
    (select volume_a from a where a.id=b.id);
    exception
    when others then
    update b
    set volume_b=(select sum(volume_a) from a where a.id=b.id);
    end;
    /