在 MySQL 中使用 LIMIT 和 OFFSET 时返回哪些行?

2021-11-20 00:00:00 mysql

在下面的查询中:

SELECT column 
FROM table
LIMIT 18 OFFSET 8

我们将获得多少结果作为输出以及从哪里到哪里?

how many results will we get as output and from where to where?

推荐答案

它将返回从记录 #9 开始到记录 #26 结束的 18 个结果.

It will return 18 results starting on record #9 and finishing on record #26.

首先从 offset 读取查询.首先偏移 8,这意味着您跳过查询的前 8 个结果.然后限制为 18.这意味着您考虑记录 9、10、11、12、13、14、15、16.....24、25、26,总共 18 条记录.

Start by reading the query from offset. First you offset by 8, which means you skip the first 8 results of the query. Then you limit by 18. Which means you consider records 9, 10, 11, 12, 13, 14, 15, 16....24, 25, 26 which are a total of 18 records.

检查这个.

还有官方文档.

相关文章