Efficient JSP paging query

xiaoxiao2021-03-06  153

<% @ page language = "java" import = "java.util. *, java.sql. *"%> <% @ page contenttype = "text / html; charSet = GB2312"%> <% int curpage = 1; // Current page INT Page_record = 20; / / // Using the number of records per page // use the following method (SQL query completion, speed fast) CURPAGE = Integer.Parseint (Request.GetParameter ("page"))))))))); // Get the passed value, need to display page ResultSet rs = cn.rsexecuteQuery ( "select top" page_record "* from tablename where id not in (select top" (curpage * page_record) "id from tablename order by id desc) order by id desc"); / / This query statement is the 20 records of the 1000 pages you want to display, and the rough ideas are - subquery exclude all records before the records you need to display. The parent query is descended in descending while (rs.next). {OUT.PRINTLN (RS.Getint ("ID"). TOSTRING ());} rs.close ();%>

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

New Post(0)