加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql 常用分页计算

发布时间:2020-12-13 17:35:02 所属栏目:百科 来源:网络整理
导读:1. 输入参数 nPageSize 每页包含的记录数量 nPageIndex 要显示的页码,=1 strOrderByFieldName 排序字段 strOrderByDirection 排序方向 other 其他查询条件 2. 计算总页数 nTotalCount 总的记录数,从 select count(*) from xxx where other 取得值 nPageCou

1. 输入参数

nPageSize 每页包含的记录数量

nPageIndex 要显示的页码,>=1

strOrderByFieldName 排序字段

strOrderByDirection 排序方向

other 其他查询条件

2. 计算总页数

nTotalCount 总的记录数,从 select count(*) from xxx where other 取得值

nPageCount 总的页数

nPageCount = (nTotalCount-1)/nPageSize+1

3. 计算记录的开始索引(不包含)

nRecordIndex 记录的开始索引(不包含)

nRecordIndex = nPageSize*(nPageIndex-1)

4. 获取最后结果

select count(*) from xxx

where other

ORDER BY [#strOrderByFieldName] [#strOrderDirection]

LIMIT [#nPageSize] OFFSET [#nRecordIndex]


转至http://blog.csdn.net/guo_rui22/article/details/4323277

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读