日期:2014-05-18  浏览次数:20384 次

帮忙看看sql语局
select   *   from   表   where   字段1   is   not   Null   and   字段2   is   Null  

我要实现再结果集中   筛选出   字段1不为空   和   字段2是空的   同时具备的条件,怎么无结果显示啊!     问题出再哪了!

------解决方案--------------------
Create Table 表
(字段1 Int,
字段2 Int)
Insert 表 Select 1, Null
Union All Select Null, Null
Union All Select 3, 5
GO
select * from 表 where 字段1 is not Null
select * from 表 where 字段2 is Null
select * from 表 where 字段1 is not Null and 字段2 is Null
GO
Drop Table 表
--Result
/*
字段1 字段2
1 NULL
3 5

字段1 字段2
1 NULL
NULL NULL

字段1 字段2
1 NULL
*/
------解决方案--------------------
select * from 表 where 字段1 is not Null and 字段2 is Null

楼主写的本身就是对的.没数据的话,应该是本身就不存在满足条件的记录.