table1有100条记录

awjx 2003-08-20 10:26:09
table1有100条记录,现我想分页查询,即每页显示10条记录,用SQL语句可以做到吗?怎样写?
...全文
32 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
awjx 2003-08-20
  • 打赏
  • 举报
回复
我还是有一点不懂,因为每的行数是一个输入参数@start
即接受程序的@start参数,返回每页@start行!
CrazyFor 2003-08-20
  • 打赏
  • 举报
回复
查询N-M条记录。
select IDENTITY(int,1,1) as iid,* into #temptable from yourtable
select top M-N * from #temptable where iid>=N

OR:

select top M-N * from yourTable where id not in(select top N-1 id from table)
ID为表具有唯一值的任何字段
hjb111 2003-08-20
  • 打赏
  • 举报
回复
能:

declare @n int
declare @s varchar
set @n=1
set @s='1'
select identity(int,1,1) as idd,* into #t from table1
while @n<>91
begin
exec('select * from #t where '+@S+' between '+@s+'10'')
set @n=@n+10
set @s=cast(@n as varchar(3))
end

go


pengdali 2003-08-20
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
select * from #temp where ID_Num between 10 and 20
pengdali 2003-08-20
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
select * from #temp where ID_Num between 10 and 20

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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