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
and ::= cond 'AND' cond

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
or ::= cond 'OR' cond

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 ::= 'NOT' cond

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.