Database Paging Learning

Source: Internet
Author: User

Recent projects using paging, learning the following several common Database page query statements, as follows, "reproduced in The Guardian panda":

1.oracle Database Paging SELECT * FROM (select A.*,rownum rc from table name where Rownum<=endrow) a where a.rc>=startrow

2.DB2 Database Paging SELECT * FROM (select RowNumber () over () as rc,a.* from (SELECT * from table name order by column name) as a) where RC between S Tartrow and Endrow

3.SQL Server 2000 database Paging Select top pagesize * FROM table name where column name not in (Select top pagesize*page column name from table name order by column name) Orde R by Column name

4.SQL Server 2005 Database Paging SELECT * FROM (select column name, Row_ search number () over (Order by column name 1) as alias from table name) as T where T. Column name 1>=start Row and T. Column name 1<=endrow

5.MySQL Database Paging Select * FROM table name limit startrow,pagesize (pagesize number of records displayed per page)

6.PostgreSQL Database Paging Select * FROM table name limit Pagesize,offset StartRow (pagesize the number of records displayed per page.)

7. General Mode SELECT * FROM (SELECT * from tb_student where SID is not in (the Select Sid from Tb_student where rownum<= (currentpage- 1) *pagesize)) where RowNum <=pageSize;


In addition, you can use Spring Management Ibatis's IOC container Sqlmapclientfactorybean to implement paging functionality in your project, such as:

public class Objcheckdaoimpl extends Sqlmapclientdaosupport implements Iobjcheckdao {
/*
* (Non-javadoc)
* @see Com.ailk.bomc.report.check.dao.iobjcheckdao#queryobjcheckinfo ( Com.ailk.bomc.report.check.bean.ObjCheckBean)
*/
Public list<objcheckbean> Queryobjcheckinfo (objcheckbean objcheckbean, int page, int limit) {


Return (list<objcheckbean>) this.getsqlmapclienttemplate (). queryForList ("Objcheck.queryobjcheck", Objcheckbean, (page-1) *limit, limit);

}
}

Database Paging Learning

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.