分页查询SQL&&Page对象

xiaoxiao2021-02-27  536

Mysql 分页查询: select * from 表明 where 1=1 limit 0,10 limit 0,10 0 代表数据库里 记录 起始行的下标 =(当前页页码-1)*每页显示的数据量 10代表每页 多少条 SQL Server 语法 :select top 3 * from NEWS where ID not in (select top 0 ID from NEWS) 内层 select top 0 ID from NEWS 0 代表数据库里 记录 起始行的下标 =(当前页页码-1)*每页显示的数据量 外层 select top 3 代表每次 返回多少条

//page 类用来做分页 public class Page { //current page 当前页码 private int currPage; //pagesize 每页数量 private int pageSize; //total count 总条数 private int totalCount; //totalpage 总页数 private int totalPageCount; public int getCurrPage() { return currPage; } public void setCurrPage(int currPage) { this.currPage = currPage; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public int getTotalCount() { return totalCount; } public void setTotalCount(int totalCount) { //设置记录总条数时,顺便计算一下总页数 this.totalCount = totalCount; if(totalCount%pageSize==0){ this.totalPageCount = totalCount/pageSize; }else{ this.totalPageCount = totalCount/pageSize+1; } } public int getTotalPageCount() { return totalPageCount; } public Page(int currPage, int pageSize, int totalCount, int totalPageCount) { super(); this.currPage = currPage; this.pageSize = pageSize; this.totalCount = totalCount; this.totalPageCount = totalPageCount; } public Page() { super(); // TODO Auto-generated constructor stub } }
转载请注明原文地址: https://www.6miu.com/read-298.html

最新回复(0)