Hacker News new | past | comments | ask | show | jobs | submit login

Same in SQL Server.. this is documented behavior

Also a null is no equal to anything.. not even another null

This will print false in SQL Server

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




> 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...


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...


where coalesce(null_column,'') = ''

shortcuts "OR is null", works within functions.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: