分页查询SQL&&Page对象
2017-05-03 23:33
330 查看
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 代表每次 返回多少条
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 } }
相关文章推荐
- Hibernate中用纯SQL查询,并通过hibernate分页返回List<对象>
- mybatis的分页插件pagehelper-fix使用、数据库分页查询模板sql、总结mysql与oracle语句的区别
- Hibernate查询,返回new对象(注意这个新定义的类要有构造函数),使用sql带条件分页查询并且把结果显示到一个对象的集里面的解决方案
- 把用SQL查询的分页对象转化为内容为Object的分页对象
- Hibernate查询,返回new对象(注意这个新定义的类要有构造函数),使用sql带条件分页查询并且把结果显示到一个对象的集里面的解决方案
- Hibernate(二)HQL&SQL参数绑定、投影和分页以及命名查询
- myBatis动态Sql查询与PageHelper分页插件
- Hibernate(二)HQL&SQL参数绑定、投影和分页以及命名查询
- 最优化的分页查询T-SQL
- Microsoft SQL Server 2005 查询分页
- 海量数据库的查询优化及分页算法方案(二)-改良SQL语句 [转]
- SQL Server Top Clause 分页查询 Paging
- 在SQL Server中通过SQL语句实现分页查询
- ACCESS模糊查询like的解决方法&&SQL查询语句通配符问题
- Sql : 多表联合查询分页
- 又一个通用分页存储过程,支持表别名,多表联合查询SQL语句
- ORACLE分页查询SQL语法
- 利用标准的SQL语句实现查询记录分页
- 海量数据库的查询优化及分页算法方案 2 之 改良SQL语句
- 用标准的SQL语句实现查询记录分页