A newer version of this documentation is available.

View Latest

Logical Operators

  • reference
    +

    Logical terms let you combine other expressions using Boolean logic. SQL++ provides the following logical operators:

    • AND

    • OR

    • NOT

    In SQL++, logical operators have their usual meaning; however, Boolean propositions can evaluate to NULL or MISSING as well as to TRUE and FALSE. The truth tables for these operators therefore use four-valued logic.

    AND

    and ::= cond 'AND' cond
    Syntax diagram

    AND evaluates to TRUE only if both conditions are TRUE.

    Table 1. AND Truth Table
    TRUE FALSE NULL MISSING

    TRUE

    TRUE

    FALSE

    NULL

    MISSING

    FALSE

    FALSE

    FALSE

    FALSE

    FALSE

    NULL

    NULL

    FALSE

    NULL

    MISSING

    MISSING

    MISSING

    FALSE

    MISSING

    MISSING

    OR

    or ::= cond 'OR' cond
    Syntax diagram

    OR evaluates to TRUE if one of the conditions is TRUE.

    Table 2. OR Truth Table
    TRUE FALSE NULL MISSING

    TRUE

    TRUE

    TRUE

    TRUE

    TRUE

    FALSE

    TRUE

    FALSE

    NULL

    MISSING

    NULL

    TRUE

    NULL

    NULL

    NULL

    MISSING

    TRUE

    MISSING

    NULL

    MISSING

    NOT

    not ::= 'NOT' cond
    Syntax diagram

    NOT evaluates to TRUE if the condition is FALSE, and vice versa.

    Table 3. NOT Truth Table
    NOT

    TRUE

    FALSE

    FALSE

    TRUE

    NULL

    NULL

    MISSING

    MISSING

    For further details, refer to Boolean Logic.