I understand why these 2 statements are false
NULL LIKE 'X'
NULL NOT LIKE 'X'
However, what I don’t understand is why these are :
NOT (NULL LIKE 'X')
NOT (NULL NOT LIKE 'X')
For example, these two statements should, I think, return different values :
SELECT CASE WHEN NOT (NULL LIKE 'X') THEN 'True' ELSE 'False' END
SELECT CASE WHEN (NULL LIKE 'X') THEN 'True' ELSE 'False' END
SQL uses a three-valued logic. You say that these are all false:
but that’s actually not true. They’re all null, which is neither true nor false.
A
WHENorWHEREclause rejects non-true values, which means null values as well as false ones, so it may seem like null is the same as false, but as you’ve noticed, it’s not. 🙂