MySQL Limit Offset syntax

Source: Internet
Author: User

MySQL supports the syntax for limit and offset. This article is mainly used for memo

We set up a table for the experiment:

MySQL>createtable  limit_offset (       int  Primarykey,      varchar(+)    0 rows affected (0.01 sec) 

Insert data: INSERT into Limit_offset (name) value (val), we insert 20 data

Mysql> Select *  fromLimit_offset;+----+--------+|Id|Name|+----+--------+|  1 |Name1||  2 |Name2||  3 |Name3||  4 |Name4||  5 |Name5||  6 |Name6||  7 |Name7||  8 |Name8||  9 |Name9|| Ten |Name10||  One |Name11||  A |Name12||  - |Name13||  - |Name14||  the |Name15||  - |Name16||  - |Name17||  - |Name18||  + |Name19||  - |Name20|+----+--------+ -Rowsinch Set(0.00Sec

Usage one: limit m. The syntax is to select the first M bar in the resultset, including M

Mysql> Select *  fromLimit_offset limit6;+----+-------+|Id|Name|+----+-------+|  1 |Name1||  2 |Name2||  3 |Name3||  4 |Name4||  5 |Name5||  6 |Name6|+----+-------+6Rowsinch Set(0.00Sec

Usage two: Limit m,n. The syntax is to select the N record from the beginning of the ResultSet record, excluding m

Mysql> Select *  fromLimit_offset limitTen,6;+----+--------+|Id|Name|+----+--------+|  One |Name11||  A |Name12||  - |Name13||  - |Name14||  the |Name15||  - |Name16|+----+--------+6Rowsinch Set(0.00Sec

Usage Three: limit m offset N. Indicates that the M record is selected from the nth record, excluding n (with limit n,m) equivalent

Mysql> Select *  fromLimit_offset limit6OffsetTen;+----+--------+|Id|Name|+----+--------+|  One |Name11||  A |Name12||  - |Name13||  - |Name14||  the |Name15||  - |Name16|+----+--------+6Rowsinch Set(0.00Sec

MySQL Limit Offset syntax

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.