Generate paging discourse for MySQL, SQL Server, and Oracle Data

Source: Internet
Author: User
The paging statement *** @ Title: getMySQLSql * @ Description: generate an SQL paging statement * @ paramsql * @ paramoffset * @ paramlimit * @ returnString * publicStringgetMySQLSql (Stringsql, effecffset, intlimit) {re

Generate paging statements for MySQL, SQL Server, and Oracle Data/*** @ Title: getMySQLSql * @ Description: generate an SQL paging statement * @ param SQL * @ param offset * @ param limit * @ return String */public String getMySQLSql (String SQL, int offset, int limit) suitable for MySQL Dialects) {re

Generate paging statements for MySQL, SQL Server, and Oracle Data
/*** @ Title: getMySQLSql * @ Description: generate an SQL paging statement * @ param SQL * @ param offset * @ param limit * @ return String */public String getMySQLSql (String SQL, int offset, int limit) suitable for MySQL Dialects) {return SQL + "limit" + offset + "," + limit;}/*** @ Title: getSqlServeSql * @ Description: generate an SQL paging statement * @ param SQL * @ param pageNo * @ param pageSize * @ return String */public String getSqlServeSql (String SQL, int pageNo, int pageSize) suitable for dialect) {return "select top" + pageSize + "from (" + SQL + ") t where t. id not in (select top "+ (pageNo-1) * pageSize +" t1.id from ("+ SQL +") t1) ";}/*** @ Title: getOrcaleSql * @ Description: generates an SQL paging statement * @ param SQL * @ param pageNo * @ param pageSize * @ return String */public String getOrcaleSql (String SQL, int pageNo, int pageSize) {return "select * from (select rownum rn, t. * from ("+ SQL +") t where rownum <= "+ (pageNo * pageSize) +") t1 where t1.rn> "+ (pageNo-1) * pageSize );}

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.