oracle中条件更新用case when结构,举例举中歼如下:
用法如下培桥:
update test set column1=
(case testCond
when ' ' then 'xxx'
else yyy end )
这样就可以更具某个正冲字段的值来更新另外一个字段了。
通用sql:
update ss
set bengtime = case when bengtime is null then sysdate else bengtime end,
endtime = case when endtime is null then sysdate else endtime end
where id = ...
或者,简早档单点渗睁腔:丛衫
update ss
set bengtime = nvl(bengtime,sysdate),
endtime =nvl(endtime,sysdate)
where id = ...
update ss set bengtime=decode(bengtime ,null,sysdate-1,bengtime),endtime=decode(bengtime,null,endtime,sysdate) where id=xxxxx;