9.4. Skip

9.4.1. Skip first three
9.4.2. Return middle two

SKIP enables the return of only subsets of the total result. By using SKIP, the result set will get trimmed from the top. Please note that no guarantees are made on the order of the result unless the query specifies the ORDER BY clause.

Figure 9.4. Graph


9.4.1. Skip first three

To return a subset of the result, starting from the fourth result, use the following syntax:

Query. 

MATCH (n)
RETURN n
ORDER BY n.name
SKIP 3

The first three nodes are skipped, and only the last two are returned in the result.

Result

n
2 rows

Node[0]{name:"D"}

Node[1]{name:"E"}


Try this query live. create (_0 {`name`:"D"}) create (_1 {`name`:"E"}) create (_2 {`name`:"A"}) create (_3 {`name`:"B"}) create (_4 {`name`:"C"}) create _2-[:`KNOWS`]->_3 create _2-[:`KNOWS`]->_4 create _2-[:`KNOWS`]->_0 create _2-[:`KNOWS`]->_1 match (n) return n order by n.name skip 3

9.4.2. Return middle two

To return a subset of the result, starting from somewhere in the middle, use this syntax:

Query. 

MATCH (n)
RETURN n
ORDER BY n.name
SKIP 1
LIMIT 2

Two nodes from the middle are returned.

Result

n
2 rows

Node[3]{name:"B"}

Node[4]{name:"C"}


Try this query live. create (_0 {`name`:"D"}) create (_1 {`name`:"E"}) create (_2 {`name`:"A"}) create (_3 {`name`:"B"}) create (_4 {`name`:"C"}) create _2-[:`KNOWS`]->_3 create _2-[:`KNOWS`]->_4 create _2-[:`KNOWS`]->_0 create _2-[:`KNOWS`]->_1 match (n) return n order by n.name skip 1 limit 2