Logical operators in Azure Cosmos DB for NoSQL
APPLIES TO:
NoSQL
Logical operators in Azure Cosmos DB for NoSQL compare two different expressions with boolean (true
/false
) operands.
Logical operators operate on boolean values. The following tables show the logical truth tables for each operator.
The OR
operator returns true
when either of the conditions is true
.
true |
false |
undefined |
|
---|---|---|---|
true |
true |
true |
true |
false |
true |
false |
undefined |
undefined |
true |
undefined |
undefined |
The AND
operator returns true
when both expressions are true
.
true |
false |
undefined |
|
---|---|---|---|
true |
true |
false |
undefined |
false |
false |
false |
false |
undefined |
undefined |
false |
undefined |
The NOT
operator reverses the value of any boolean expression.
NOT |
|
---|---|
true |
false |
false |
true |
undefined |
undefined |
The logical operators OR
, AND
, and NOT
have the precedence level indicated here.
Priority | |
---|---|
NOT |
1 |
AND |
2 |
OR |
3 |
The special operator *
projects the entire item as is. When used, it must be the only projected field. A query like SELECT * FROM products p
is valid, but SELECT VALUE * FROM products p
or SELECT *, p.id FROM products p
aren't valid.