【发布时间】:2021-09-16 19:54:06
【问题描述】:
我有一张桌子test
------------------------------
id | date | description
------------------------------
1 | 07/08/09 | the date no 1.
10 | 07/08/10 | the date no 2.
3 | 07/08/11 | the date no 3.
9 | 07/08/12 | the date no 4.
... | ... | ...
我知道我可以像这样选择第一页(用于键集分页)
SQL 编号1
select t.id as id, t.date as record_date, t.description as description
from test t order by t.id LIMIT 2
需要将最后一条记录(3 | 07/08/11 | the date no 3.)保存到缓存中
用于下一页查找。
可以使用
检索下一页SQL 编号2
select t.id as id, t.date as record_date, t.description as description
from test t where t.id > 3 order by t.id LIMIT 2
记住我的分页看起来像这样
| << | < | > | >> |
在哪里
>下一页
>>超级最后一页
<上一页
<<超级首页
如何选择超级最后一页的记录?
如何选择上一页的记录?
超级首页如何选择记录?
是否可以选择一个查询 当前选定的记录数 + 选定的记录 + 该查询的可用记录总数?
【问题讨论】:
标签: postgresql