This question is out of a databases exam i was looking at, so it might be nothing one can ever use in a real situation...
What output does the following valid SQL statement produce? Explain your answer!
SELECT (NULL = NULL);
I can easily produce the output of the statement, which is
school=> select (null = null); ?column? ---------- (1 row)
in psql 8.4.11, but how and why this is the answer i don't know... I would have guessed it tries to evaluate the expression inside the brackets and comes up with true/false but apparently it doesn't.
Any hints on why it behaves like it does?
Thanks
null != null(or to use the inequality operator specified in the SQL standard,null <> null) is also neither true nor false, since you can't say that two unknown values are known to be not equal. See @Oded's answer.select ARRAY[null]::bigint[] && ARRAY[null]::bigint[]?