MYSQL LIMIT Usage Detailed

Source: Internet
Author: User

In MySQL's limit usage, there is a discussion on the Internet:

"//In order to retrieve all record rows from one offset to the end of the recordset, you can specify a second parameter of-1:

Mysql> SELECT * from table LIMIT 95,-1; Retrieves the record line 96-last. "

The person who wrote this sentence certainly did not actually do it, because it was wrong.

inch  for ' -1 ' 3

Take a look at MySQL's official documentation: http://dev.mysql.com/doc/refman/6.0/en/select.html

The LIMIT clause can used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or both numeric arguments, which must both be nonnegative integer constants (-1 back off!) )with these exceptions:

Within prepared statements, LIMIT parameters can be specified using? Placeholder markers.

Within stored programs, LIMIT parameters can be specified using integer-valued routine parameters or local variables.

With a arguments, the first argument specifies the offset of the first row to return, and the second specifies the m Aximum number of rows to return. The offset of the initial row is 0 (not 1):

SELECT * from TBL LIMIT 5, 10; # Retrieve rows 6-15


To retrieve all rows from a certain offsetup to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

SELECT * from TBL LIMIT 95,18446744073709551615;


With one argument, the value specifies the number of rows to return from the beginning of the result set:

SELECT * from TBL LIMIT 5; # Retrieve First 5 rows
In other words, limit row_count are equivalent to limit 0, Row_count.

MYSQL LIMIT Usage Detailed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.