Logical operators

Supported datatypes: BOOLEAN

Logical operators allow to chain multiple boolean columns or expressions that return boolean value to obtain more complex logical expressions.

AND

The logical conjunction operator returns TRUE value if and only if both inputs are TRUE.

Truth table for AND

Input 1

Input 2

Result

FALSE

FALSE

FALSE

FALSE

TRUE

FALSE

TRUE

FALSE

FALSE

TRUE

TRUE

TRUE

FALSE

NULL

FALSE

TRUE

NULL

NULL

NULL

TRUE

NULL

NULL

FALSE

FALSE

NULL

NULL

NULL

See also

OR, NOT

Examples

Simple conjunction of two boolean columns.

SELECT <col_1_bool> AND <col_2_bool>
FROM <table_name>

Negated column syntax.

SELECT <col_1_bool> AND NOT <col_2_bool>
FROM <table_name>

OR

The logical disjunction (or alternative) operator returns TRUE value if one of the inputs is TRUE.

Truth table for OR

Input 1

Input 2

Result

FALSE

FALSE

FALSE

FALSE

TRUE

TRUE

TRUE

FALSE

TRUE

TRUE

TRUE

TRUE

FALSE

NULL

NULL

TRUE

NULL

TRUE

NULL

TRUE

TRUE

NULL

FALSE

NULL

NULL

NULL

NULL

See also

AND, NOT

Examples

Simple disjunction of two boolean columns.

SELECT <col_1_bool> OR <col_2_bool>
FROM <table_name>

Negated column syntax.

SELECT <col_1_bool> OR NOT <col_2_bool>
FROM <table_name>

NOT

The logical negation operator returns the reverse truth value.

Truth table for NOT

Input

Result

FALSE

TRUE

TRUE

FALSE

NULL

NULL

See also

AND, OR

Example

Simple negation of a boolean column.

SELECT NOT <col_1_bool>
FROM <table_name>