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:

    The surest route to breeding jealousy is to compare. Since jealousy comes from feeling “less than” another, comparisons only fan the fires.
    Dorothy Corkville Briggs (20th century)

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

    Somebody who should have been born
    is gone.

    Yes, woman, such logic will lead
    to loss without death. Or say what you meant,
    you coward . . . this baby that I bleed.
    Anne Sexton (1928–1974)