Oracle, MySQL and sqlserve The difference introduction of three kinds of database paging query statements _mssql

Source: Internet
Author: User

First define the several parameters that the paging statement will use:

int currentpage; Current page
int Pagerecord; Show number of records per page

Take the previous AddressBook datasheet for example (10 records per page):

One, Sqlserve download page statements

String sql = "SELECT top" +pagerecord + "* from AddressBook where ID is not in (select Top" + (currentpage-) *pagerecord + "id from T_user) "; 

Second Page SQL Demo:

Select top of * from AddressBook where ID. (select top ID from addressbook)

Second, MySQL database paging statements

String sql = "SELECT * from AddressBook where limit" + (currentpage-) *pagerecord + ", +pagerecord +" "; 
SELECT * FROM table name "condition" Limit m,n; 
M to start with the first few records, such as the display of each page record, the second page must start from the first record 

Second Page SQL Demo:

SELECT * from AddressBook where limit 10,10

Iii. Oracle Database Page-Splitting statements

 
 

Second Page SQL Demo:

SELECT * FROM (select RowNum rn,t.* from AddressBook where rownum<=) where rownum > 10

The above is a small set to introduce the Oracle, MySQL and sqlserve three kinds of database paging query statements of the difference, I hope to help!

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.