读书人

条件替换解决方法

发布时间: 2012-02-05 12:07:14 作者: rapoo

条件替换
有表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))

读书人网 >VFP

热点推荐