Usage of limit in SQLite

Source: Internet
Author: User

In Sqlite3, the structure of the top syntax is not used, and the Sqlite3 uses limit to achieve such a function.

The data in the MyTable table is as follows:

ID Value

1 Hello

2 You

3 You

4 Very Good

5 !

The following SQL statement: SELECT * FROM MyTable limit 3; The query results shown are:

1 Hello

2 You

3 You

Equivalent to top 3 in SQL Server, but limit has a more powerful function than top, especially in the paging feature.

The following SQL statement: SELECT * FROM MyTable limit 1, 3;

The results shown are:

2 You

3 You

4 Very Good

The limit m,n means starting with the first record and fetching N Records (starting from 0, and the 2nd record starting from 1, one analogy). Therefore, starting from the third record, then m=2, such as starting from the 6th record to fetch data, fetch 10, the SQL statement is as follows: SELECT * FROM MyTable limit 5, 10;


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.