I was confused behind the reasoning of the following:
SELECT * FROM table WHERE avalue is null
Returns x number of rows where 'avalue' is null
SELECT * FROM table WHERE avalue <> true
Does not return rows where 'avalue' is null.
My reasoning (which appears to be incorrect) is that as null is a unique value (it isn't even equal to null) means that it should show in the result set as it isn't equal to true either.
I guess you could argue that by saying column <> value you imply that the column has a value therefore ignoring the null values altogether.
What is the reasoning behind this and is this the same in other common SQL DB's?
My reasoning (assumption) is telling me this is counter-intuitive and I wanted to learn why.
<>aretrueorfalse- whereas in SQL, there is the option ofunknown. This is in the standards. (Confusingly, MySQL conflatesUNKNOWNandNULLso there, the possible results areTRUE,FALSEandNULL)SELECT * FROM table WHERE avalue is not trueshould include which 'avalue' is null