Operators
You can use various types of operators in your SQL queries to perform operations on your data.
Logical Operators
You can use the following logical operators in SQL queries:
- AND
- BETWEEN (Includes endpoints. For example, if a query states WHERE age BETWEEN 10 AND 20, Node returns both 10 and 20 in the result.)
- IN
- LIKE
- NOT
- OR
Comparison Operators
You can use the following comparison operators in your SQL queries:
- <
- >
- <=
- >=
- =
- <>
- IS NULL
- IS NOT NULL
- IS FALSE
- IS NOT FALSE
- IS TRUE
- IS NOT TRUE
Pattern Matching Operators
You can use the LIKE pattern matching operator in your SQL queries.
Math Operators
You can use the following math operators in your SQL queries:
| Operator | Description |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
Subquery Operators
You can use the following subquery operators in your SQL queries:
- EXISTS
- IN
See [SELECT Statements](/docs/select).
String Concatenate Operator
You can use the following string operator in your SQL queries to concatenate strings:
- string || string
The concatenate operator is an alternative to the concat function and will concatenate input if Node can implicitly convert the input to a string.
The concat function treats NULL as an empty string. The concatenate operator (||) returns NULL if any input is NULL.
Operator Precedence
The following table shows the precedence of operators in decreasing order:
| Operator/Element | Associativity | Description |
|---|---|---|
| . | left | dot notation used, for example, to step down in a JSON map |
| left | array-style notation to step down into a JSON array | |
| - | right | unary minus |
| E | left | exponentiation |
| * / % | left | multiplication, division, modulo |
| + - | left | addition, subtraction |
| IS | IS TRUE, IS FALSE, IS UNKNOWN, IS NULL | |
| IS NULL | test for null | |
| IS NOT NULL | test for not null | |
| (any other) | left | all other native and user-defined operators |
| IN | set membership | |
| BETWEEN | range containment, includes end points | |
| OVERLAPS | time interval overlap | |
| LIKE ILIKE | string pattern matching | |
| SIMILAR TO NOT SIMILAR TO | string pattern matching | |
| < > | less than, greater than | |
| = | right | equality, assignment |
| NOT | right | logical negation |
| AND | left | logical conjunction |
| OR | left | logical disjunction |