update table1 a set rybh=(select max(rybh) from talbe2 b where a.sfzh=b.sfzh group by rybh) 
我要将B表中的人员编号更新为A表中的,B表中存在一个身份证号对应多个人员编号,执行报错:
ORA-01427: single-row subquery returns more than one row
这个该怎么写

解决方案 »

  1.   

    update table1 a set rybh=(select max(rybh) from talbe2 b where a.sfzh=b.sfzh 
    --group by rybh
    --这个max(rybh),又group by, 从语义来讲是错误的。去掉即可
      

  2.   

      select max(rybh) from talbe2 b where a.sfzh=b.sfzh group by rybh
    检索的结果返回多个值 , “set rybh=”只能有一个值, 
      

  3.   

    update table1 a set rybh=(select max(rybh) from talbe2 b where a.sfzh=b.sfzh )