SELECT * FROM table limit [offset,] rows | Rows Offset Offset
The limit clause can be used to force a SELECT statement to return the specified number of records. Limit accepts one or two numeric parameters. parameter must be an integer constant. Given two parameters, the first parameter specifies the offset of the first row to return the record, and the second parameter specifies the maximum number of rows to be returned. The initial record line offset is 0 (instead of 1): For compatibility with PostgreSQL, the MySQL tutorial also supports syntax: Limit # offset #.
Mysql> select * FROM table limit 5, 10; Retrieve Record Row 6-15
To retrieve all row rows from an offset to the end of a recordset, you can specify a second argument of-1:
Mysql> select * from table limit 95,-1; Retrieves the record row 96-last.
If only one argument is given, it represents the maximum number of record rows returned:
Mysql> select * from table limit 5; Retrieve the first 5 rows of records
In other words, limit n is equivalent to limit 0,n.
Note the differences between limit 10 and limit 9,1:
For example:
1.
SELECT * FROM Cyclopedia where id>= (
Select Max (ID) from (
Select ID from Cyclopedia ORDER by ID limit 90001
) as TMP
) limit 100;
2.
SELECT * FROM Cyclopedia where id>= (
Select Max (ID) from (
Select ID from Cyclopedia ORDER by ID limit 90000,1
) as TMP
) limit 100;