为什么 NOT IN (NULL) 总是什么都不返回 [英] Why NOT IN (NULL) Always returns nothing

查看:50
本文介绍了为什么 NOT IN (NULL) 总是什么都不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下表:

以及以下简单查询:

I have following table:

And following simple query:

SELECT * FROM dbo.Calendars WHERE calname NOT IN(NULL)

我的问题是为什么总是 NOT IN(NULL) 什么都不返回?
PS:不管你的表是什么,如果你将NOT IN(NULL)添加到任何列的条件中,结果什么都不是.提前谢谢你:)

My question is why always NOT IN(NULL) return nothing?
PS:No matter what is your table,if you add NOT IN(NULL) to any column's condition,result is nothing. Thank you in advance :)

推荐答案

因为 value equals NULL 未定义,永远不会计算为 True.查看这篇关于不良做法的帖子.不要使用INNULL,使用EXISTS 来测试至少一行存在的东西.

Because value equals NULL is not defined, and will never evaluate to True. Check This post on bad practices. Don't use IN and NULL, use EXISTS to test for at least one row where something exists.

这篇关于为什么 NOT IN (NULL) 总是什么都不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆