Database paging Statement (MySQL, Oracle, sqlserver, DB2)

Source: Internet
Author: User

MySQL:

Select * from table name where pid = 0 limit (current page-1) * per page), per page

ORACLE:

Select * from (

Select rownum as RN, source. * from (
SQL statement
) Source where rownum <= (current page * number of entries per page)
) Result where rn> = (current page-1) * How much is displayed on each page)

Sqlserver:

How many * from table name where primary key column not in is displayed on each page of select top?

(Select top (current page-1) * Number of primary key columns displayed on each page from table name order by primary key columns)

Order by primary key column

How to increase the query speed when primary key columns increase automatically

Select top: How many columns are displayed on each page * from table name where primary key column>

(Select max (primary key column) from (select (current page-1) * Number of primary key columns displayed on each page from table name order by primary key column ))

Order by primary key column

 

 

DB2

 

Select * from (
Select row_number () over () as rownum, source .*
From (

SQL statement
) Source
)
Where rownum> = (current page-1) * number of entries per page) and rownum <= (current page * number of entries per page)

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.