id fund1 fund2
1 0.00 234
2 123 0.00如上表,我想更新 如果 fund1的值为0.00那么更新fund2.反之更新fund1我写的语句如下,不能执行
update table a set decode('0.00',fund2,'fund1','fund2 ' ) = '250' where id ='1'简单点说就是 if fund1>0 执行
update table a set fund1= '250' where id ='1';
if fund2>0 执行
update table a set fund2= '250' where id ='1';用一句语句怎么写谢谢!!
1 0.00 234
2 123 0.00如上表,我想更新 如果 fund1的值为0.00那么更新fund2.反之更新fund1我写的语句如下,不能执行
update table a set decode('0.00',fund2,'fund1','fund2 ' ) = '250' where id ='1'简单点说就是 if fund1>0 执行
update table a set fund1= '250' where id ='1';
if fund2>0 执行
update table a set fund2= '250' where id ='1';用一句语句怎么写谢谢!!
试试
1 0.00 234
2 123 0.00
update tab1 set fund1=(case when fund2>0 then 250 else fund1 end),
fund2=(case when fund1>0 then 250 else fund2 end)
where id='1'
fund2 = (case when fund2 > 0 then 250 else fund2 end)
where id = 1;
found1= case when found1=0 then '250' else found1 end,
found2= case when found1=0 then found2 else '250' end
where id ='1'
;
fund2=decode(fund1,0,250,fund2)
where id=1
decode或case中的字段类型楼主注意匹配