MySQL Query the first few lines to the first few lines of the statement _mysql

Source: Internet
Author: User
1, query the first line of records:
SELECT * FROM table Limit 1
2, inquires the nth row to the M line record
SELECT * FROM table1 limit n-1,m-n;
SELECT * FROM table LIMIT 5, 10; Returns records from line 6th to line 15th
SELECT * FROM Employee limit 3, 1; Back To Line 4th
3, the query before the N line records
SELECT * FROM table1 limit 0,n;
Or
SELECT * FROM table1 limit n;
4, the query after the N line records
SELECT * FROM table1 ORDER BY id desc dlimit n;//reverse order, take the first n row ID as the self-added form
5, query a record ($id) of the next record
SELECT * FROM table1 where id> $id ORDER by ID ASC Dlimit 1
6, query a record ($id) of the previous record
SELECT * FROM table1 where id< $id order BY id desc dlimit 1

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.