Null (SQL) - Comparisons With NULL and The Three-valued Logic (3VL)

Comparisons With NULL and The Three-valued Logic (3VL)

Further information: Three-valued logic

Since Null is not a member of any data domain, it is not considered a "value", but rather a marker (or placeholder) indicating the absence of value. Because of this, comparisons with Null can never result in either True or False, but always in a third logical result, Unknown. The logical result of the expression below, which compares the value 10 to Null, is Unknown:

SELECT 10 = NULL -- Results in Unknown

However, certain operations on Null can return values if the value of Null is not relevant to the outcome of the operation. Consider the following example:

SELECT NULL OR TRUE -- Results in True

In this case, the fact that the value on the left of OR is unknowable is irrelevant, because the outcome of the OR operation would be True regardless of the value on the left.

SQL implements three logical results, so SQL implementations must provide for a specialized three-valued logic (3VL). The rules governing SQL three-valued logic are shown in the tables below (p and q represent logical states)" The truth tables SQL uses for AND, OR, and NOT correspond to a common fragment of the Kleene and Ɓukasiewicz three-valued logic (which differ in their definition of implication, however SQL defines no such operation).

Read more about this topic:  Null (SQL)

Famous quotes containing the words comparisons, null and/or logic:

    I don’t like comparisons with football. Baseball is an entirely different game. You can watch a tight, well-played football game, but it isn’t exciting if half the stadium is empty. The violence on the field must bounce off a lot of people. But you can go to a ball park on a quiet Tuesday afternoon with only a few thousand people in the place and thoroughly enjoy a one-sided game. Baseball has an aesthetic, intellectual appeal found in no other team sport.
    Bowie Kuhn (b. 1926)

    A strong person makes the law and custom null before his own will.
    Ralph Waldo Emerson (1803–1882)

    You can no more bridle passions with logic than you can justify them in the law courts. Passions are facts and not dogmas.
    Alexander Herzen (1812–1870)