Skip to content

SKIP clause

Marijn van Wezel edited this page Dec 15, 2022 · 1 revision

The SKIP clause defines from which row to start including the rows in the output. It takes the number of rows to skip.

Query::skip(int|IntegerType $amount): Query

Parameters

  • $amount : The amount to skip.

Relevant methods

  • setSkip(int|IntegerType $skip): self : Set the amount to skip.

Examples

Skip first three rows

$n = node();
$query = query()
    ->match($n)
    ->returning($n->property('name'))
    ->orderBy($n->property('name'))
    ->skip(3)
    ->build();

$this->assertStringMatchesFormat("MATCH (%s) RETURN %s.name ORDER BY %s.name SKIP 3", $query);

Return middle two rows

$n = node();
$query = query()
    ->match($n)
    ->returning($n->property('name'))
    ->orderBy($n->property('name'))
    ->skip(1)
    ->limit(2)
    ->build();

$this->assertStringMatchesFormat("MATCH (%s) RETURN %s.name ORDER BY %s.name SKIP 1 LIMIT 2", $query);

Using an expression with SKIP

$n = node();
$query = query()
    ->match($n)
    ->returning($n->property('name'))
    ->orderBy($n->property('name'))
    ->skip(integer(5)->exponentiate(2))
    ->build();

$this->assertStringMatchesFormat("MATCH (%s) RETURN %s.name ORDER BY %s.name SKIP (5 ^ 2)", $query);

External links