PHP - Previous and Next Links - The LIMIT Clause
(Page 2 of 5 )
The LIMIT clause of the SQL SELECT statement is going to be our bread and butter here. It is how we are going to retrieve the exact rows that we want from the database.
LIMIT takes either one or two arguments. With one argument, it limits the amount of returned rows by that number.
SELECT * FROM table LIMIT 5 |
The proceeding SQL statement returns the first 5 rows of the table. If we use LIMIT with two arguments, the first argument specifies what row to start on and the second is how many rows to return. Note that rows in SQL start with 0 (zero), not 1 (one).
SELECT * FROM table LIMIT 5, 5 |
That last SQL statement will return rows 6 through 10 from the database.
The LIMIT clause is not difficult, but it is imperative that you understand how it works in order to accomplish our goal.
Next: Starting Off with $start >>
More Database Articles Articles
More By Matt Wade
|
| · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | · | | | | |
|