英文:
How to select all rows, skipping the first 10 by using LIMIT and OFFSET?
问题
Let's assume the table has 110 rows. The following skips the first 10 rows and returns the other 100:
SELECT ... FROM ... ORDER BY ... LIMIT 10, 100
Is there a way to replace 100
by whatever is left?
Desired pseudo-code:
SELECT ... FROM ... ORDER BY ... LIMIT 10, *
英文:
Let's assume the table has 110 rows. The following skips the first 10 rows and returns the other 100:
SELECT ... FROM ... ORDER BY ... LIMIT 10, 100
Is there a way to replace 100
by whatever is left?
Desired pseudo-code:
SELECT ... FROM ... ORDER BY ... LIMIT 10, *
答案1
得分: 2
要检索从某个偏移量到结果集末尾的所有行,可以使用一个大数作为第二个参数。此语句检索从第96行到最后的所有行:
SELECT * FROM tbl LIMIT 95,18446744073709551615;
英文:
>To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:
>
>SELECT * FROM tbl LIMIT 95,18446744073709551615;
答案2
得分: 0
SELECT * FROM TABLE_NAME LIMIT (SELECT count(*) FROM TABLE_NAME) OFFSET 10;
不确定执行时间。
SELECT count(*) FROM TABLE_NAME
这返回可用行数。
英文:
SELECT * FROM TABLE_NAME LIMIT (SELECT count(*) FROM TABLE_NAME) OFFSET 10;
Not sure about the execution time though.
SELECT count(*) FROM TABLE_NAME
This is returning the number of available rows
答案3
得分: 0
只返回翻译好的部分:
从 (
选择 *,行号() Over(按ID ASC排序) RN 从 表
) as vw
其中 RN > 10
英文:
Select * from (
Select *,Row_Number() Over(Order By ID ASC) RN From Table
) as vw
where RN >10
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论