LIMIT constrains the number of records in the output.
Introduction
LIMIT accepts any expression that evaluates to a positive integer.
Return a subset of the rows
To return a subset of the result, starting from the top, use the following syntax:
Query
SELECT *FROM cypher('graph_name', $$MATCH (n) RETURN n.nameORDER BY n.nameLIMIT 3$$) as (names agtype);
The name property of the matched node n is returned, with a limit of 3.
Result
| names |
| “A” |
| “B” |
| “C” |
| 3 rows |
Using an expression with LIMIT to return a subset of the rows
LIMIT accepts any expression that evaluates to a positive integer as long as it is not referring to any external variables:
Query
SELECT *FROM cypher('graph_name', $$MATCH (n)RETURN n.nameORDER BY n.nameLIMIT toInteger(3 * rand()) + 1$$) as (names agtype);
Returns one to three top items.
Result
| names |
| “A” |
| “B” |
| 2 rows |
