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]

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...