sybase中isnull()用法

来源:互联网 发布:爱淘宝店 编辑:程序博客网 时间:2024/06/15 17:55
sybase中isnull()用法
现在有这样一个问题:
比如一个表中的a字段有几种取值:0,1,10,NULLWHERE条件过滤时a<>10和isnull(a,0)<>10有什么区别么前者能得到NULL的记录么?
答案:
前者不可以,后者可以 这个没问题测试情况如下create table #aa(    a    int  null ,   b int,) insert #aa(a,b) values (1,1)insert #aa(a,b) values (10,10)insert #aa(a,b) values (0,0)insert #aa(b) values (20)select * from #aa where a<>10(2 rows affected)
结果:
a           b           ----------- -----------  1           1  0           0 
select * from #aa where isnull(a,0)<>10(3 rows affected)结果如下:a b ----------- ----------- 1 1 0 0 NULL 20
继续……select isnull(null,0)可以看出结果为0说明为空的时候为0