Booleans ======== Construction ------------ +--------------------+-------------------------------------------------+ | | Description | +====================+=================================================+ | ``false`` | Boolean value false. | +--------------------+-------------------------------------------------+ | ``true`` | Boolean value true. | +--------------------+-------------------------------------------------+ | ``bool()`` | Constructs a boolean where zero becomes false | | | whilst every other number is true. | +--------------------+-------------------------------------------------+ AND --- Boolean operator AND. *Syntax:* .. code:: sql AND For example: .. code:: sql true and true // true false and false // false true and false // false true and null // null false and null // false null and null // null OR -- .. code:: sql OR Boolean operator OR. For example: .. code:: sql true or true // true false or false // false true or false // true true or null // true false or null // null null or null // null NOT --- Boolean operator NOT. *Syntax:* .. code:: sql NOT For example: .. code:: sql not true // false not false // true not null // null Comparisons ----------- Equalities follow SQL null semantics, where a comparison with null returns null since the value is unknown: .. code:: sql true = true // true true = null // null true = false // false null = null // null true <> null // null null <> null // null For inequalities, a comparison with null also returns null since the value is unknown. Moreover, for inequalities, the value ``false`` is considered smaller than ``true``. .. code:: sql null < false // null false < true // true true >= false // true Casts ----- Booleans can be casted to: - strings, where true becomes "true" and false becomes "false"; - numbers, where true is 1 and false is 0.