请问怎样写才能抽出第20-第30条记录

vcppman 2004-01-04 08:03:46
我在写网页分页

我想写一条sql语句,让他抽出符合条件的记录的第20到第30条

用select top只能抽前多少条,却不能抽中间的记录,

请问大家,有办法吗?
...全文
28 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
verge 2004-01-05
  • 打赏
  • 举报
回复
select xuhao=identity(int,1,1),* into #t from gdk
select * from #t where xuhao>=20 and xuhao<=30
sandychen 2004-01-05
  • 打赏
  • 举报
回复
當table中沒有ID欄位時,用以下程式來實現.
create proc p_top
@a int,
@b int
as
select * into #t from ieel00h
select * from #t where uid>=@a and uid<=@b

go

execute p_top @a=200,@b=300
leus 2004-01-05
  • 打赏
  • 举报
回复
select id=identity(int,1,1),* into #t from gdk
select * from #t where id>=20 and id<=30
leus 2004-01-05
  • 打赏
  • 举报
回复
select id=identity(int,1,1),* into #t from gdk
select * from #t where id>=20 and id<=30
gmlxf 2004-01-04
  • 打赏
  • 举报
回复
SELECT TOP 11 *
FROM
(SELECT TOP 30 * FROM T ORDER BY ID) a
ORDER BY ID DESC
OpenVMS 2004-01-04
  • 打赏
  • 举报
回复
有唯一的一列数据吗? 如 id

select top 11 * from yourtable
where id not in (select top 19 id from yourtable)


jingxijun 2004-01-04
  • 打赏
  • 举报
回复
示例如下:
select xuhao=identity(int,1,1),* into #t from gdk
select * from #t where xuhao>=20 and xuhao<=30

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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