Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 6847d34

Browse files
authored
skip/limit doc (#341)
* skip/limit doc * Update limit.md * Update limit.md * Update skip.md
1 parent 123c28d commit 6847d34

File tree

2 files changed

+100
-16
lines changed

2 files changed

+100
-16
lines changed

src/content/docs/cypher/query-clauses/limit.md

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,58 @@ LIMIT 3;
1818
```
1919
Result:
2020
```
21-
-----------
22-
| u.name |
23-
-----------
24-
| Zhang |
25-
-----------
26-
| Karissa |
27-
-----------
28-
| Adam |
29-
-----------
21+
┌─────────┐
22+
│ u.name │
23+
│ STRING │
24+
├─────────┤
25+
│ Zhang │
26+
│ Karissa │
27+
│ Adam │
28+
└─────────┘
3029
```
3130

3231
If you omit the `ORDER BY`, you would get some k tuples in a `LIMIT k` query
3332
but you have no guarantee about which ones will be selected.
3433

34+
35+
The number of rows to limit can either be:
36+
1. A parameter expression when used with prepared statement:
37+
38+
Prepare:
39+
```c++
40+
auto prepared = conn->prepare("MATCH (u:User) RETURN u.name limit $lt")
41+
```
42+
Execution:
43+
The number of rows to limit can be given at the time of execution.
44+
```c++
45+
conn->execute(prepared.get(), std::make_pair(std::string{"lt"}, 1))
46+
```
47+
48+
Result:
49+
```
50+
┌────────┐
51+
│ u.name │
52+
│ STRING │
53+
├────────┤
54+
│ Adam │
55+
└────────┘
56+
```
57+
2. A literal expression which can be evaluated at compile time.
58+
```cypher
59+
MATCH (u:User)
60+
RETURN u.name
61+
limit 1+2
62+
```
63+
Result:
64+
65+
```
66+
┌─────────┐
67+
│ u.name │
68+
│ STRING │
69+
├─────────┤
70+
│ Adam │
71+
│ Karissa │
72+
│ Zhang │
73+
└─────────┘
74+
```
75+

src/content/docs/cypher/query-clauses/skip.md

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,57 @@ SKIP 2;
2020
```
2121
Result:
2222
```
23-
-----------
24-
| u.name |
25-
-----------
26-
| Karissa |
27-
-----------
28-
| Zhang |
29-
-----------
23+
┌─────────┐
24+
u.name
25+
│ STRING │
26+
├─────────┤
27+
│ Karissa │
28+
Zhang
29+
└─────────┘
3030
```
3131

3232
If you omit the `ORDER BY`, you would skip some k tuples in a `SKIP` k query
3333
but you have no guarantee about which ones will be skipped.
34+
35+
36+
The number of rows to skip can either be:
37+
1. A parameter expression when used with prepared statement:
38+
39+
Prepare:
40+
```c++
41+
auto prepared = conn->prepare("MATCH (u:User) RETURN u.name skip $sp")
42+
```
43+
44+
Execution:
45+
46+
The number of rows to skip can be given at the time of execution.
47+
```c++
48+
conn->execute(prepared.get(), std::make_pair(std::string{"sp"}, 2))
49+
```
50+
51+
Result:
52+
```
53+
┌────────┐
54+
│ u.name │
55+
│ STRING │
56+
├────────┤
57+
│ Zhang │
58+
│ Noura │
59+
└────────┘
60+
```
61+
2. A literal expression which can be evaluated at compile time.
62+
```cypher
63+
MATCH (u:User)
64+
RETURN u.name
65+
skip 2+1
66+
```
67+
Result:
68+
69+
```
70+
┌────────┐
71+
│ u.name │
72+
│ STRING │
73+
├────────┤
74+
│ Noura │
75+
└────────┘
76+
```

0 commit comments

Comments
 (0)