Why NOT IN (NULL) Always returns nothing

前端 未结 3 2051
不知归路
不知归路 2021-01-24 12:33

I have following table:

And following simple query:

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

My question is why always <

3条回答
  •  萌比男神i
    2021-01-24 13:07

    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.

提交回复
热议问题