Home > Database > Mysql Tutorial > body text

高效的jsp分页查询_MySQL

WBOY
Release: 2016-06-01 14:10:50
Original
1131 people have browsed it

Jsp如下:
**********************



int curpage=1;//当前页
int page_record=20;//每页显示的记录数
//用下面的方法(sql查询完成,速度快)
curpage=Integer.parseInt(request.getParameter("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");
//本查询语句得到的是所要显示的1000页的20条记录,大致思路为――子查询排除需要显示的记录前的所有记录,父查询则对余下的记录进行降序排列
while(rs.next) {
  out.println(rs.getInt("id").toString());
}
rs.close();
%>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template