注册 登录
编程论坛 ASP技术论坛

怎样查询表第5条道第10条的数据

dhdhzzw 发布于 2008-03-19 13:25, 877 次点击
SQL怎样查询表第5条道第10条的数据
我想查询第5条到第10条的数据
请问怎样写?
5 回复
#2
madpbpl2008-03-19 15:04
select top 6 * from [tb] where id not in (select top 4 id from [tb])
#3
dhdhzzw2008-03-19 15:59
[bo]以下是引用 [un]madpbpl[/un] 在 2008-3-19 15:04 的发言:[/bo]

select top 6 * from [tb] where id not in (select top 4 id from [tb])



按楼上的那样写出错了///

select top 6 * from updata where user_id not in (select top 4 user_id from updata)
====
服务器: 消息 208,级别 16,状态 1,行 1
对象名 'updata' 无效。
服务器: 消息 208,级别 16,状态 1,行 1
对象名 'updata' 无效。


我的updata为 表名  user_id 为自动排序
#4
madpbpl2008-03-19 16:19
sql server?
select top 6 * from [updata] where user_id not in (select top 4 user_id from [updata]) as a
这样呢?
#5
dhdhzzw2008-03-19 17:48
我知道了,这样写的
select * from tablename where id between 5 and 10    ---选择id为5到10之间的数据而不是第五列到第十列

====================
select   top   5   *   from   tablename   where   id   not   in   (select   top   10   id   from   tablename) order by id desc
----选择第5条到第10条数据倒序输出
#6
dhdhzzw2008-03-19 17:55
[bo]以下是引用 [un]madpbpl[/un] 在 2008-3-19 15:04 的发言:[/bo]

select top 6 * from [tb] where id not in (select top 4 id from [tb])

谢谢楼上的,这句话对了,是我写错了东西,,谢谢了。。。。。。。。。。。。。。。。。。。。
1