SQL> select * from test;A B ---------- ---------- 0001 0001 0001 SQL> update test set a=decode(a||'-'||b,'0001-0001','0002','0001-','0002',a), 2 b=decode(a||'-'||b,'0001-0001','0002',b);已更新3行。SQL> select * from test;A B ---------- ---------- 0002 0002 0002 SQL>
update test set A = decode(A,'0001','0002',A), B = decode(B,'0001','0002',B) where A = '0001' and (B = '0001' or B is null)
bzszp(SongZip)大侠真是个天才,构思太巧妙了!
update test set b='0002' where b='0001' and a='0001'; update test set a='0002' where a='0001';
---------- ----------
0001 0001
0001
SQL> update test set a=decode(a||'-'||b,'0001-0001','0002','0001-','0002',a),
2 b=decode(a||'-'||b,'0001-0001','0002',b);已更新3行。SQL> select * from test;A B
---------- ----------
0002 0002
0002
SQL>
A = decode(A,'0001','0002',A),
B = decode(B,'0001','0002',B)
where
A = '0001' and (B = '0001' or B is null)
update test set a='0002' where a='0001';