如何按范围选择行? [英] How can I select rows by range?

查看:19
本文介绍了如何按范围选择行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<块引用>

可能的重复:
SQLite中识别行号的Select语句

例如,SELECT * FROM table WHERE [row] BETWEEN x AND y

这是怎么做到的?我已经阅读了一些资料,但没有发现任何特别正确的内容.

想象一个列表,您希望结果按 X 个结果分页,因此对于第 10 页,您需要从 10 * X 到 10 * X + X 行的结果.而不是一次性显示所有结果

解决方案

对于 mysql 你有限制,你可以触发查询:

SELECT * FROM table limit 100` -- 获取第 100 条记录SELECT * FROM table limit 100, 200` -- 获取从第 101 行开始的 200 条记录

对于 Oracle,您可以使用 rownum

查看limit的mysql select语法和用法这里.

对于 SQLite,你有 limit, offset.我没有使用过 SQLite,但我在 SQLite 文档 上检查了它.在此处查看 SQLite 示例.

Possible Duplicate:
Select statement in SQLite recognizing row number

For example, SELECT * FROM table WHERE [row] BETWEEN x AND y

How can this be done? I've done some reading but haven't found anything specifically correct.

Imagine a list where you want results paged by an X amount of results, so for page 10 you would need results from rows 10 * X to 10 * X + X. Rather than display ALL results in one go

解决方案

For mysql you have limit, you can fire query as :

SELECT * FROM table limit 100` -- get 1st 100 records
SELECT * FROM table limit 100, 200` -- get 200 records beginning with row 101

For Oracle you can use rownum

See mysql select syntax and usage for limit here.

For SQLite, you have limit, offset. I haven't used SQLite but I checked it on SQLite Documentation. Check example for SQLite here.

这篇关于如何按范围选择行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆