你的表中有主键吗?
说句你不高兴的话,在实际中几乎没有这种需求。
还是写一下吧:
update your_table set c3='aa',c4='bb' where c1=1;
update your_table set c3='cc',c4='dd' where c1=3;
update your_table set c3='ee',c4='ff' where c1=5;
update your_table set c3='',c4='' where c1=7;
commit;
update your_table set c3='',c4='' where c1 is null;
commit;
说句你不高兴的话,在实际中几乎没有这种需求。
还是写一下吧:
update your_table set c3='aa',c4='bb' where c1=1;
update your_table set c3='cc',c4='dd' where c1=3;
update your_table set c3='ee',c4='ff' where c1=5;
update your_table set c3='',c4='' where c1=7;
commit;
update your_table set c3='',c4='' where c1 is null;
commit;
primary_column c c1 c2 c3 c4
---------------------------------------------------------
1 01 1 2
2 01 3 4
3 01 5 6
4 01 7 8
5 01 aa bb
6 01 cc dd
7 01 ee ff
update table_name set c3=cc,c4=dd where c1=3 and c4=4;
update table_name set c3=dd,c4=ee where c1=5 and c5=6;
写了不止一个了 :)
primary_column c c1 c2 c3 c4
---------------------------------------------------------
1 01 1 2
2 01 3 4
3 01 5 6
4 01 7 8
5 01 aa bb
6 01 cc dd
7 01 ee ff
( select e.c3,e.c4 from
( select a.primary_column,a.c1,a.c2,b.c3,b.c4
from ( select rownum no,primary_column,c,c1,c2 from yourtable where c3 is null and c4 is null) a,
( select rownum no,c1,c2 from yourtable where c1 is null and c2 is null) b
where a.no=b.no(+)
) e
where d.primary_column = e.primary_column
)
where d.c1 is not null and d.c2 is not null and d.c3 is null and d.c4 is null
不要用到数据库中算了。看来你只能一条条update了