database - 在 postgresql 中以 block 的形式检索数据

标签 database postgresql database-design

我想分块获取数据(使用 select 查询),比如第一次尝试从 1 到 50 条记录,第二次尝试从 51 到 100 条记录。

最佳答案

使用LIMITOFFSET。以下查询在跳过前 50 条记录后返回 50 条记录,因此返回记录 51 - 150。

SELECT fname, lname 
FROM students
ORDER BY ssn
LIMIT 100 OFFSET 50;

https://www.postgresql.org/docs/current/static/queries-limit.html

关于database - 在 postgresql 中以 block 的形式检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42081971/

相关文章:

sql - 自定义 jsonb 键排序顺序

postgresql - 如何只允许特定用户访问数据库?

mysql - 如何设计问答数据库(MySql)

c# - 从 C# 导出到 Excel 不显示数据库中的第一行

xml - 为什么人们会使用纯 XML 数据库而不是普通的 RDBM?

ruby-on-rails - 如何从 Rails 取消昂贵的 Postgresql 查询?

mysql - 我想在数据库中存储公制单位——我应该使用什么数据类型?

sql-server - 递归选择

database - Postgresql:遍历每个表并检查列?

sql - 如何在 API 的查询字符串中设计通用过滤运算符?