一个简单的数据库查询问题———100分!

数据库查询中,使用select top 1000 * from TableName 以后,怎样显示查询后边跟着的1000条记录,望高手不吝赐教!!
[73 byte] By [I_wanttoknow-什么都不懂] at [2008-5-11]
# 1
你的意思是想分页显示,

设一个分页标记
select top 1000 * from TableName
where bh>T //T 是分页标记, T第一次存储的是0,第二次存的是1000

这样就行了。

向上翻页有些复杂。

order by Bh desc

你可以看我以前问的这个贴子.有正确的答案

My_first-小@_@小 at 2007-10-27 > top of Msdn China Tech,Delphi,数据库相关...
# 2
用一个DBGrid,指定Datasource,指定DataSource的DataSet就能显示了
bigysw-大花脸 at 2007-10-27 > top of Msdn China Tech,Delphi,数据库相关...
# 3
不知道你说什么?
# 4
最好建立索引

然后用索引号查询下1000条记录
ddvboy-ddv-我心憔悴 at 2007-10-27 > top of Msdn China Tech,Delphi,数据库相关...
# 5
必须设一个分页标记否则没有好办法了
select top 1000 * from TableName
where bh>T

feelingluck888-啊华 at 2007-10-27 > top of Msdn China Tech,Delphi,数据库相关...
# 6
下面的SQL查询出1001~2000条记录

select * from tb where rownum<=2000
minus
select * from tb where rownum<=1000

这样写的速度更快:
select * from ( select rownum rn,tb.* from tb where rownum<=2000) where rn>=1000

caim-感谢君儿 at 2007-10-27 > top of Msdn China Tech,Delphi,数据库相关...
# 7
同意楼上的
xiachedan-瞎扯蛋 at 2007-10-27 > top of Msdn China Tech,Delphi,数据库相关...
# 8
去看看精华帖吧
http://www.Codefund.cn/expert/topic/959/959195.xml?temp=.2457392
caim-感谢君儿 at 2007-10-27 > top of Msdn China Tech,Delphi,数据库相关...