首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-02-01 
返回NULL值的记录表pid字段1字段21a……2b……3c……4null……select*fromawhere字段1 c结果只返回第1、2条记录,

返回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 '

热点排行