sql server获取除null值以外的值 [英] sql server get values other than null values
本文介绍了sql server获取除null值以外的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi Frnds,
我有桌子
Table1
ID姓名部门
1 A NULL
2 B IT
3 C IT
4 D NULL
i需要输出如下
ID名称部门
1 A NULL
4 D NULL
我使用
select * from Table1 where Dept !=''IT''(也是Dept<>''IT'')
此查询未获取,如何获取值
解决方案
试试这个:
选择 * < span class =code-keyword> from Table1 where Dept!= ' IT' 或部门 IS NULL
更多信息: http://msdn.microsoft.com/en-us/library/ms191504.aspx [<一个href =http://msdn.microsoft.com/en-us/library/ms191504.aspxtarget =_ blanktitle =New Window> ^ ]
< blockquote>你好朋友
你可以尝试这个...
- 如果您想获得所有空值
SELECT * FROM 表1 WHERE 部门 IS NULL
- 如果你想获得非NULL值的全部
SELECT * FROM Table1 WHERE 部门 IS NOT NULL
你不能比较为NULL。
试试这个:
从table1中选择*,其中Dept为空;
Hi Frnds,
I am having Table
Table1
ID Name Dept
1 A NULL
2 B IT
3 C IT
4 D NULL
i need output as follows
ID Name Dept
1 A NULL
4 D NULL
I used
select * from Table1 where Dept!=''IT'' (also where Dept<>''IT'')
this query not getting,how to get values
解决方案
Hi, try this:
select * from Table1 where Dept!='IT' OR Dept IS NULL
More info here: http://msdn.microsoft.com/en-us/library/ms191504.aspx[^]
Hello freind
can you try this...
--If you want to get All NULL value SELECT * FROM Table1 WHERE Dept IS NULL --If you want to get All which are not NULL value SELECT * FROM Table1 WHERE Dept IS NOT NULL
You can''t compare to NULL.
Try this:
select * from table1 where Dept is null;
这篇关于sql server获取除null值以外的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文