Hacker News new | ask | show | jobs
by magicalhippo 2322 days ago
> Also a null is no equal to anything.

Wrong. It is equal to UNKNOWN:

https://docs.microsoft.com/en-us/sql/t-sql/queries/is-null-t...

2 comments

I don't think that's what it says.

If I'm reading it right, (null = null) is unknown, which is falsy (except with ansi_nulls off, then it'll be true). (null is null) is true.

I don't think you can test null = (null = null), i.e. null = unknown. Let me know if that's possible somehow, I can't get it working.

Sorry brainfart, was responding to the second part, ie comparison to another null.
so?.. still not equal to anything, two unknowns are not equal

if null = null print 'true' else print 'false'

It's equal to something: the value UNKNOWN. This influences for example how the comparison result is used in compound expressions:

https://docs.microsoft.com/en-us/sql/t-sql/language-elements...