sybase中isnull()的用法

来源:百度知道 编辑:UC知道 时间:2024/06/23 23:40:49
比如一个表中的a字段有几种取值:0,1,10,NULL
WHERE条件过滤时
a<>10
和isnull(a,0)<>10有什么区别么
前者能得到NULL的记录么

前者不可以,后者可以,因为isnull函数加上后会把null值全都当做0来处理

以上,希望对你有所帮助!

首先:前者不可以,后者可以 这个没问题

测试情况如下
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)
select * from #aa where isnull(a,0)<>10
(3 rows affected)
结果如下:
a b
----------- -----------
1 1
0 0

a b
----------- -----------
1 1
0 0
NULL 20

select isnull(null,0)可以看出结果为0说明为空的时候为0