Operators¶
The following table lists the operators supported by GQL.
| Precedence | Operator | Description | Arity | Null behavior | Example |
|---|---|---|---|---|---|
| 1 | . | Gets a property of a node or edge, or a field of a record. | 2 | default | RETURN n.name |
| 2 | [] | Gets an element in a list by index. | 1 | default | RETURN n.hobbies[0] |
| 3 | * | Multiplication | 2 | default | RETURN n.salary * 2 |
| 3 | / | Division | 2 | default | RETURN n.salary / 2 |
| 4 | + | Addition | 2 | default | RETURN n.salary + 1000 |
| 4 | - | Subtraction | 2 | default | RETURN n.salary - 500 |
| 5 | < | Less-than comparison | 2 | default | WHERE n.age < 30 RETURN n |
| 5 | > | Greater-than comparison | 2 | default | WHERE n.age > 30 RETURN n |
| 5 | <= | Less-than-or-equal comparison | 2 | default | WHERE n.age <= 30 RETURN n |
| 5 | >= | Greater-than-or-equal comparison | 2 | default | WHERE n.age >= 30 RETURN n |
| 5 | = | Equality comparison | 2 | default | WHERE n.age = 30 RETURN n |
| 5 | <> | Inequality comparison | 2 | default | WHERE n.age <> 30 RETURN n |
| 6 | IN | Checks whether the operand is contained in a list. | 2 | general | WHERE n.age IN [25,30,35] RETURN n |
| 6 | LIKE | Pattern matching | 2 | default | WHERE n.name LIKE 'John%' RETURN n |
| 7 | IS NULL | Checks whether the operand is NULL. |
1 | general | WHERE n.email IS NULL RETURN n |
| 7 | IS NOT NULL | Checks whether the operand is not NULL. |
1 | general | WHERE n.email IS NOT NULL RETURN n |
| 8 | NOT | Logical NOT | 1 | default | WHERE NOT n.is_adult RETURN n |
| 9 | AND | Logical AND | 2 | default | WHERE n.is_adult AND n.age > 18 RETURN n |
| 10 | OR | Logical OR | 2 | default | WHERE n.is_adult OR n.age > 18 RETURN n |
| 10 | XOR | Logical XOR | 2 | default | WHERE n.is_adult XOR n.age > 18 RETURN n |
| lowest | = | Assignment | 2 | N/A | MATCH (n{id:10}) SET n.age = 31 |