declare @pagecounts
int
set @pagecounts=2
declare @page int
set @page=1
select top
@pagecounts * from (select
b.id,b.lnames,b.job,b.dt,c.compName,d.type,b.userdomain,b.tel
from Main a
left join users b on a.tabid=b.id left join company c on c.userid=b.id left join
linkType d on d.id=b.type
where a.structureid=1 and a.uin=20062718 ) as
tb
where id not in (select top (@page-1)*@pagecounts b.id from Main a left
join users b on a.tabid=b.id left join company c on c.userid=b.id left join
linkType d on d.id=b.type
where a.structureid=1 and a.uin=20062718)
分页
最新推荐文章于 2025-02-05 08:00:00 发布
本文介绍了一种使用SQL实现的数据分页查询方法。通过具体示例展示了如何设置和使用变量来实现分页功能,包括定义每页显示的记录数及当前页数等关键步骤。
32万+

被折叠的 条评论
为什么被折叠?



