MySQL Select limit
The LIMIT keyword in MySQL is used to limit the maximum number of query records returned.
... LIMIT offset, rows
In this syntax, offset represents the pointer to the data record, rows represents the maximum number of records returned by the query, and both parameters must be integers.
SELECT username FROM user LIMIT 4,10
If there are more than 14 data records in the user table, the example returns 5-14 records (10 in total). Note that the default offset is 0.
Offset parameter, if omitted, the default is 0, that LIMIT 10 is equivalent to LIMIT 0,10.
Rows in the LIMIT do not support the value -1 (from the current offset to the end of the table record all the data), such as:
SELECT username FROM user LIMIT 9, -1
Running the SQL generates a parameter error.
When you confirm the query results only one data (such as checking the user name password), you can add LIMIT 1 restrictions, when the system queries to a data after the search will not continue to search the next record, which can effectively improve the query effectiveness.