I have a query where a row is selected when
field1 <> 10.
field1 is null, this predicate is
According to my primitive maths, if
null <> 10 = false, then
10 = null.
What is the rational for this?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
This is because a comparison to
NULL actually results in unknown.
NULL is the absence of data and so you are comparing a value against nothing and the result cannot be determined.
When null values are present in data, logical and comparison operators can potentially return a third result of UNKNOWN instead of just TRUE or FALSE. This need for three-valued logic is a source of many application errors. These tables outline the effect of introducing null comparisons.
Taken from the documentation on MSDN.