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:

    Decade after decade, artists came to paint the light of Provincetown, and comparisons were made to the lagoons of Venice and the marshes of Holland, but then the summer ended and most of the painters left, and the long dingy undergarment of the gray New England winter, gray as the spirit of my mood, came down to visit.
    Norman Mailer (b. 1923)

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

    Neither Aristotelian nor Russellian rules give the exact logic of any expression of ordinary language; for ordinary language has no exact logic.
    Sir Peter Frederick Strawson (b. 1919)