Logical Operators
- reference
Logical terms let you combine other expressions using Boolean logic. N1QL provides the following logical operators:
-
AND
-
OR
-
NOT
In N1QL, 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
condition AND condition
AND evaluates to TRUE only if both conditions are TRUE.
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
condition OR condition
OR evaluates to TRUE if one of the conditions is TRUE.
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 condition
NOT evaluates to TRUE if the condition is FALSE, and vice versa.
NOT | |
---|---|
TRUE |
FALSE |
FALSE |
TRUE |
NULL |
NULL |
MISSING |
MISSING |
Related Links
For further details, refer to Boolean Logic.