当前位置: 代码迷 >> VFP >> 条件替换解决方法
  详细解决方案

条件替换解决方法

热度:419   发布时间:2013-02-26 00:00:00.0
条件替换
有表A:
A     B     C    
2     3    
5     5    
1     3  
1     4


要求:
当a> =2   and   b> =2,c=你好
当a> =1   and   b> =3,c=谢谢

------解决方案--------------------------------------------------------
&&你的这个题目有些问题,如果a=5,b=5,既满足a> =2 and b> =2又满足a> =1 and b> =3,该如何?
create table 表A (a n(1),b n(1),c c(4))
insert into 表A values (2,3, " ")
insert into 表A values (5,5, " ")
insert into 表A values (1,3, " ")
insert into 表A values (1,4, " ")

update 表A set c=iif((a> =2 and b> =2), "你好 ",iif((a> =1 and b> =3), "谢谢 ", " "))
select * from 表A
------解决方案--------------------------------------------------------
update tt set c=iif(a> =2 and b> =2, '你好 ',iif(a> =1 and b> =3, '谢谢 ',c))
  相关解决方案