postgresql 常用分页计算
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |