- Neo4j Tutorial
- Neo4j - Home
- Neo4j - Overview
- Neo4j - Data Model
- Neo4j - Environment Setup
- Neo4j - Building Blocks
- Neo4j CQL Write Clauses
- Neo4j - Merge Command
- Neo4j - Set Clause
- Neo4j - Delete Clause
- Neo4j - Remove Clause
- Neo4j - Foreach Clause
- Neo4j CQL Read Clause
- Neo4j - Match Clause
- Neo4j - Optional Match Clause
- Neo4j - Where Clause
- Neo4j - Count Function
- Neo4j CQL General Clauses
- Neo4j - Return Clause
- Neo4j - Order By Clause
- Neo4j - Limit Clause
- Neo4j - Skip Clause
- Neo4j - With Clause
- Neo4j - Unwind Clause
- Neo4j CQL Functions
- Neo4j - String Functions
- Neo4j - Aggregation Function
- Neo4j CQL Admin
- Neo4j - Backup & Restore
- Neo4j - Index
- Neo4j - Create Unique Constraint
- Neo4j - Drop Unique
- Neo4j Useful Resources
- Neo4j - Quick Guide
- Neo4j - Useful Resources
- Neo4j - Discussion
Neo4j CQL - LIMIT & SKIP Clauses
Neo4j CQL LIMIT clause
Neo4j CQL has provided "LIMIT" Clause to filter or limit the number of rows return by a query. It trims the results from the bottom of the CQL Query Result Set.
If we want to trim the results from the top of the CQL Query Result set, then we should go for CQL SKIP clause. Please refer next section of this chapter for CQL SKIP clause
LIMIT clause syntax
LIMIT <number>
Syntax Description
S.No. | Syntax Element | Description |
---|---|---|
1. | LIMIT | It is a Neo4j CQL keyword. |
2. | <number> | It is an inter value. |
Example
This example demonstrates how to use CQL LIMIT clause to reduce the number of records return by a MATCH + RETURN Query.
Step 1 - Open Neo4j Data Browser
It is Neo4j Data Browser Homepage
Step 2 - Type the below command on Data Browser without LIMIT clause
MATCH (emp:Employee) RETURN emp
Step 3 - Click on "Execute" button and observe the results.
It returns total number of results available in the database: 4 records
Step 4 - Type the below command on Data Browser with LIMIT clause
MATCH (emp:Employee) RETURN emp LIMIT 2
Step 5 - Click on "Execute" button and observe the results.
It returns only two results from Top as we have defined limit = 2. That means first two rows.
Neo4j CQL SKIP clause
Neo4j CQL has provided "SKIP" Clause to filter or limit the number of rows return by a query. It trims the results from the top of the CQL Query Result Set.
If we want to trim the results from the bottom of the CQL Query Result set, then we should go for CQL LIMIT clause. Please refer above section of this chapter for CQL LIMIT clause
SKIP clause syntax:
SKIP <number>
Syntax Description
S.No. | Syntax Element | Description |
---|---|---|
1. | SKIP | It is a Neo4j CQL keyword. |
2. | <number> | It is an inter value. |
Example
This example demonstrates how to use CQL SKIP clause to reduce the number of records return by a MATCH + RETURN Query.
Step 1 - Open Neo4j Data Browser
Step 2 - Type the below command on Data Browser without SKIP clause
MATCH (emp:Employee) RETURN emp
Step 3 - Click on "Execute" button and observe the results.
It returns total number of results available in the database: 4 records
Step 4 - Type the below command on Data Browser with SKIP clause
MATCH (emp:Employee) RETURN emp SKIP 2
Step 5 - Click on "Execute" button and observe the results.
It returns only two results from Bottom as we have defined skip = 2. That means last two rows.