LIMIT with OFFSET in MySQL: Understanding Query Results
The combination of LIMIT and OFFSET clauses in MySQL allows for the selection of a specific subset of rows from a table. This technique is useful for pagination and retrieval of specific data segments.
Query:
Consider the following query:
SELECT column FROM table LIMIT 18 OFFSET 8
Number and Range of Results:
This query will return 18 rows as output, starting from record #9 and ending at record #26. To determine this range, follow these steps:
Example:
Let's say we have a table with the following data:
id | column |
---|---|
1 | A |
2 | B |
3 | C |
4 | D |
5 | E |
6 | F |
7 | G |
8 | H |
9 | I |
10 | J |
11 | K |
12 | L |
13 | M |
14 | N |
15 | O |
16 | P |
17 | Q |
18 | R |
19 | S |
20 | T |
The query would return the following result:
column |
---|
I |
J |
K |
L |
M |
N |
O |
P |
Q |
R |
S |
T |
U |
V |
W |
X |
Y |
Z |
The above is the detailed content of How Does MySQL\'s `LIMIT` with `OFFSET` Determine the Range of Retrieved Rows?. For more information, please follow other related articles on the PHP Chinese website!