Skip to content

LIMIT clause

Marijn van Wezel edited this page Dec 13, 2022 · 4 revisions

The LIMIT clause constrains the number of returned rows. It accepts an integer representing the maximum number of records in the output.

Query::limit(int|IntegerType $limit): Query

Parameters

  • $limit : The amount to use as the limit.

Relevant methods

  • setLimit(int|IntegerType $limit): self : Sets the limit.

Examples

Return a limited subset of the rows

$persons = node('Person');
$query = query()
    ->match($persons)
    ->returning($persons->property('name'))
    ->limit(3)
    ->build();

$this->assertStringMatchesFormat("MATCH (%s:Person) RETURN %s.name LIMIT 3", $query);

External links