Database paging query for various databases

Source: Internet
Author: User

Data query, only with the database paging, can alleviate the data too large on the impact of the program, to avoid the appearance of memory overflow.

The following field descriptions for the various databases:

1. Table historypacking, including field Cardnumber flag ...

2. Table pickaddress, including field pickaddressid ...

1.SQL Server 2005 (2000 is not supported, support for more than 2005 versions):

SELECT * FROM (SELECT *, Row_number () Up (Order by a.time DESC) as RowNumber

From historypacking as a where a.cardnumber= ' 512000005935 ' and a.flag=0 ) as B where RowNumber between 1 and 5; (Start number and end number)

2.Oracle Database Paging

SELECT *

From (select RowNum as Num,a.* from (SELECT * from pickaddress order by Pickaddressid ASC) a) t

where T.num>=6 and t.num<=11; (sorted by Pickaddressid, result set between 6 and 11 bits, included)

For data that needs to change according to the table of the query!

3.MySQL Database paging

SELECT * from table limit m,n;

where m refers to the beginning of the record index, starting from 0, indicating the first record

n means starting from section m+1 and taking N. (N to be fixed)


This article is from "Yong Xin Technology Blog" blog, please be sure to keep this source http://rusth2015.blog.51cto.com/9973392/1618567

Database paging query for various databases

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.