<数据库问题>如何查询第n到第m条记录?

xuqiang007 2001-11-08 11:39:05
如何查询第n到第m条记录?(n<m,意思为按数据的物理顺序查询从第n到m条记录)。
...全文
90 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
karma 2001-11-09
  • 打赏
  • 举报
回复
1. if the records are ordered by some fields and you know how to calcuate the n-m records from those fields, for example, you have an identity field, you can do
select * from where id >=n and id <=m

then that will be the easiest way

2. assume m >n, in SQL Server, you can get the top m records, reverse the order, get the top m-n+1 records

3. use the above mentioned method
yxbi 2001-11-08
  • 打赏
  • 举报
回复

for i=0 to m
if i>=n then
xxxxxx' 读出数据来
end if
rs.movenext
next i
xuqiang007 2001-11-08
  • 打赏
  • 举报
回复
我想知道有没有可以执行的SQL语句来实现?
intersun 2001-11-08
  • 打赏
  • 举报
回复
笨方法,先用move方法指向第n行,再用do while语句循环遍历要查找的字段,直到第m行。

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧