sybase中isnull()用法


现在有这样一个问题:


比如一个表中的a字段有几种取值:0,1,10,NULL WHERE条件过滤时 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