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

Which rows are returned when using LIMIT with OFFSET in MySQL?(在 MySQL 中使用 LIMIT 和 OFFSET 时返回哪些行?)
本文介绍了在 MySQL 中使用 LIMIT 和 OFFSET 时返回哪些行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的查询中:

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.

检查这个.

还有官方文档.

这篇关于在 MySQL 中使用 LIMIT 和 OFFSET 时返回哪些行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)