Skip to content

Operator precedence

The following list shows the precedence of nGQL operators in descending order. Operators that are shown together on a line have the same precedence.

- (negative number)
!, NOT
*, /, %
-, +
== , >=, >, <=, <, <>, !=
AND
OR, XOR
= (assignment)

For operators that occur at the same precedence level within an expression, evaluation proceeds left to right, with the exception that assignments evaluate right to left.

The precedence of operators determines the order of evaluation of terms in an expression. To override this order and group terms explicitly, use parentheses.

Examples

nebula> RETURN 2+3*5;
+-----------+
| (2+(3*5)) |
+-----------+
| 17        |
+-----------+

nebula> RETURN (2+3)*5;
+-----------+
| ((2+3)*5) |
+-----------+
| 25        |
+-----------+

OpenCypher compatibility

In openCypher, comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent to x < y AND y <= z in openCypher. But in nGQL, it is equivalent to (x < y) <= z, which is a boolean (x < y) compare again an integer (z). And the result is NULL.


Last update: March 17, 2021
Back to top