update 多列更新

来源:互联网 发布:天津三思网络 编辑:程序博客网 时间:2024/06/08 03:13

drop table test; 

create table test

      (q1  varchar2(200),
      q2  varchar2(200),
      q3  varchar2(200)

         );

insert into test(q1,q2,q3) values('1','3','1');

insert into test(q1,q2,q3) values('','3','1');

insert into test(q1,q2,q3) values('','3','1');

insert into test(q1,q2,q3) values('','3','');

insert into test(q1,q2,q3) values('','3','');

insert into test(q1,q2,q3) values('','3','');

update test a set (a.q1,a.q3) =(select nvl(b.q1,'-'),nvl(b.q3,'-') from test b where a.rowid = b.rowid and a.rowid = b.rowid)where q1 is null and q3 is null; //空值只能这样索引,空值不等于0或空格,多列同时更新,并且多空值进行同时转换。


0 0
原创粉丝点击