update taba a set deptno=(select deptno from tabb b where a.id=b.id);

解决方案 »

  1.   

    应该这么写吧 update taba a set deptno=(select deptno from tabb b,tabA a where a.id=b.id);
      

  2.   

    update taba a set deptno=(select deptno from tabb b,tabA a where a.id=b.id);
      

  3.   

    以上三位人兄都对,但涉及到多记集时,会出错update taba a set deptno=(select deptno from tabb b where a.id=b.id rownum<=1 order by deptno .....);
      

  4.   

    update taba a set deptno=(select deptno from tabb b,tabA a where a.id=b.id);这样写不对呀,有一个致命的问题:
    taba中如果 id在 tabB中没有,则更新后结果变成null 啦,怎么办哪
      

  5.   

    应该是
    update taba a set deptno=(select deptno from tabb b,tabA a where a.id=b.id) where a.id in (select id from tabB b where a.id = b.id);
      

  6.   

    update taba a set deptno=(select deptno from tabb b,tabA a where a.id=b.id(+));
      

  7.   

    update taba a set deptno=nvl((select deptno from tabb b,tabA a where a.id=b.id(+)),0);