注册 登录
编程论坛 SQL Server论坛

用sql2000怎么取得第4条到第8条的记录

zq1983 发布于 2007-04-09 12:31, 884 次点击
我用top*只能取得前几条的记录,但是我想取得第中间一段的记录,就好象第4条到第8条的记录,应该怎么办呢.
在线等.

[此贴子已经被作者于2007-4-9 12:33:02编辑过]

9 回复
#2
初学Delphi2007-04-09 12:44
#3
zq19832007-04-09 14:52
select * from (select top 8 * from table1) as a where not exists(select top 4 * from table1)
我用了这条语句,显示的时候没有数据

[此贴子已经被作者于2007-4-9 14:55:20编辑过]

#4
初学Delphi2007-04-09 16:32

条件呢?
这样肯定没数据了。。。
exists (select )
如果select这个存在 条件成立
not exists (select )
如果select top 4不是空条件就不成立

你少了a.主键=b.主键吧?

#5
zq19832007-04-09 18:33
a,b是什么啊
#6
xiyou4192007-04-09 19:02
就是你的table1的别名
#7
棉花糖ONE2007-04-09 21:39
没主键的话,就别说要取第几条到第几条
#8
豆芽的天空2007-04-10 10:52


select top 5 * into #gh from operator
delete from #gh where operatorid = any (select top 2 operatorid from #gh)

select * from #gh

#9
Kendy1234562007-04-10 11:00
有这种要求的设个自增字段就得了
以后随便你取第几条
#10
daidaidai2007-04-10 14:03
select * from (select top 8 * from table_name) a where not exsixt ((select * from(select top 4 from table_name ) b where a.priid=b.priid )
1