几种典型的分页sql,下面例子是每页50条,198*50=9900,取第199页数据。

-写法1,not in/top
select top 50 * from pagetest 
where id not in (select top 9900 id from pagetest order by id)
order by id




--写法2,not exists
select top 50 * from pagetest 
where not exists 
(select 1 from (select top 9900 id from pagetest order by id)a  where a.id=pagetest.id)
order by id

--写法3,max/top
select top 50 * from pagetest
where id>(select max(id) from (select top 9900 id from pagetest order by id)a)
order by id

--写法4,row_number()
select top 50 * from 
(select row_number()over(order by id)rownumber,* from pagetest)a
where rownumber>9900

select * from 
(select row_number()over(order by id)rownumber,* from pagetest)a
where rownumber>9900 and rownumber<9951

select * from 
(select row_number()over(order by id)rownumber,* from pagetest)a
where rownumber between 9901 and 9950

--写法5,在csdn上一帖子看到的,row_number() 变体,不基于已有字段产生记录序号,先按条件筛选以及排好序,再在结果集上给一常量列用于产生记录序号
select *
from (
    select row_number()over(order by tempColumn)rownumber,*
    from (select top 9950 tempColumn=0,* from pagetest where 1=1 order by id)a
)b
where rownumber>9900
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以通过以下步骤来实现el-table在每页10变为每页50之后下面分页框和表头相对距离不变: 1. 在el-table组件中添加一个ref属性,例如: <el-table :data="tableData" :height="tableHeight" ref="myTable"> 2. 在需要控制样式的地方添加一个class属性,例如: <el-pagination class="my-pagination" ...> 3. 在样式表中为这个class添加样式,例如: .my-pagination { margin-top: 10px; /* 上边距为10像素 */ } 4. 在el-table组件中添加一个监听函数,监听分页事件,例如: <el-table :data="tableData" :height="tableHeight" ref="myTable" @current-change="handlePageChange"> 5. 在Vue实例中定义这个监听函数,例如: methods: { handlePageChange() { this.$nextTick(() => { const tableEl = this.$refs.myTable.$el.querySelector('.el-table__body-wrapper'); const paginationEl = document.querySelector('.my-pagination'); const margin = paginationEl.offsetTop - tableEl.offsetHeight - tableEl.offsetTop; if (margin > 0) { tableEl.style.marginBottom = margin + 'px'; } else { tableEl.style.marginBottom = '0'; } }); } } 这个函数会在分页事件触发时调用,首先使用$nextTick方法确保所有DOM元素都已经渲染完成,然后获el-table__body-wrapper元素和.el-pagination元素,计算它们之间的距离,如果距离为正数,则将el-table__body-wrapper元素的下边距设为这个距离,否则下边距为0。 这样就实现了el-table在每页10变为每页50之后下面分页框和表头相对距离不变的效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值