那你还是update完了再设置为0好了update ysadys a
set yysje=0 where yysje is null;

解决方案 »

  1.   

    问题出在语句上,而不是在nvl上
    update ysadys a
    set yysje=( select nvl(yskje,0) from ysyysje b where a.dbh=b.bh );
    -----------------
    这样写update语句,就会修改整个表,而你的表有两条记录,所以显示2条记录修改.
    而select nvl(yskje,0) from ysyysje b where a.dbh=b.bh查不到值,返回就是空值,所以yysje字段还是空值.
    -----------
    一般情况,这条语句加上一个where条件后,就不会迷惑了.
    update ysadys a
    set yysje=( select nvl(yskje,0) from ysyysje b where a.dbh=b.bh )
    where dbh in (
      select bh from ysyysje)
      

  2.   

    你的语句应该没问题,将select * from ysyysje的结果也贴出来看看。
      

  3.   

    update ysadys a
    set yysje=( select nvl(yskje,0) from ysyysje b where a.dbh=b.bh )
    where a.yysje=null
    and  a.dbh=b.bh
      

  4.   

    我的意思是使用nvl()后,yysje要么为0,要么为其它的数字,不为null,就像在SQL SERVER中使用isnull()
      

  5.   

    update ysadys a
    set yysje=( select nvl(yskje,0) from ysyysje b where a.dbh=b.bh );ysyysje的表结构是什么样子的?updatet ysadys a
    set yysje = nvl((select yskje from ysyysje b where bh = a.dbh),0);
      

  6.   

    问题出在:  表ysyysje中没有对应的记录,所以,select nvl(yskje,0) 取出来的结果不是0而是…………ora-01403:no_data_found
      当然,在这个sql语句里面是不会抛出例外的,但是返回值肯定是空值
      

  7.   

    assian(故事还没讲完呢,别走啊) 是sql是可以的.
      

  8.   

    assian(故事还没讲完呢,别走啊) 的sql是可以的.