A high efficiency method for completing the paging by SQL statement in Web development, using JSPASP as an example

zhaozj2021-02-17  46

First, the JSP method is as follows: ********************* <% @ page language = "java" import = "java.util. *, Java.sql. * "%> <% @ page contenttype =" text / html; charset = GB2312 "%> <% int curpage = 1; // Current page INT Page_Record = 20; // The number of records displayed per page // uses the following method (SQL query is completed, speed Fast) CURPAGE = INTEGER.PARSEINT (Request.getParameter ("page")); // Get the passed value, the page that needs to be displayed RS = cn.rsexecuteQuery ("SELECT TOP" Page_Record * from Tablename Where id NOT IN (Select Top " (CURPAGE * PAGE_RECORD) " ID from Tablename Order By ID "); // This query statement gets 20 records of the 1000 pages you want to display, roughly thinking - Subquerical excludes all records that need to be displayed, and the parent query is descended in descending while (rs.Next) {Out.println (RS.GetInt ("ID"). TOSTRING ());} RS. CLOSE ();%> ************ II, method in ASP ************************* *** <% @ language = "VBScript" CODEPAGE = "936"%> <% DIM CURPAGE = 1 'Current page DIM Page_Record = 20' The number of records in each page is displayed CURPAGE = Request ("Page") Getting Value, the page you need to display ... 'connection database operation code omit rs.open "SELECT TOP" PAGE_RECORD "* from Tablename WHERE ID NOT IN (SELECT TOP" (CURPAGE * Page_Record) ID FR OM Tablename Order By ID Desc) Order By ID Desc ", CONN, 1, 3 'This query statement gets 20 records of the 1000 pages you want to display, and the rough ideas are - subquery exclude all the records that need to be displayed. Record, the parent query is descended in descending sequencing for the remaining records While Not Rs.eOfResponse.Write RS ("ID") rs.movenextwendrs.closeconn.close%> *************** ***** Thanks to reading, I hope this article helps you have help you.

转载请注明原文地址:https://www.9cbs.com/read-28534.html

New Post(0)