MySQL first few lines to the first few lines of statements

Source: Internet
Author: User

1, query the first line of records:
SELECT * FROM table Limit 1
2, query the nth line to the M record
SELECT * FROM table1 limit n-1,m-n;
SELECT * FROM table LIMIT 5, 10; Returns records from Row 6th to line 15th
SELECT * FROM Employee limit 3, 1; Return To Line 4th
3, query the first n rows of records
SELECT * FROM table1 limit 0,n;
Or
SELECT * FROM table1 limit n;
4, after the query n rows of records
SELECT * FROM table1 ORDER BY id desc dlimit n;//reverse order, FETCH first n row ID for self-increment form
5, query a record ($id) the next record
SELECT * FROM table1 where id> $id ORDER by ID ASC Dlimit 1
6. Check the previous record of a record ($id)
SELECT * FROM table1 where id< $id order BY id desc dlimit 1

MySQL first few lines to the first few lines of statements

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.