读书人

返回NULL值的记录,该怎么解决

发布时间: 2012-02-01 16:58:19 作者: rapoo

返回NULL值的记录
表p

id 字段1 字段2
1 a ……
2 b ……
3 c ……
4 null ……

select * from a where 字段1 <> 'c '

结果只返回第1、2条记录,如何让第4条null值的记录也返回。

要求不要改数据。

[解决办法]
select * from a where 字段1 <> 'c ' or 字段1 is null
[解决办法]
select * from a where 字段1 <> 'c '
union all
select * from a where 字段1 is null


[解决办法]
select * from a where isnull(字段1, 'a ') <> 'c '

读书人网 >SQL Server

热点推荐