数据展示的分页处理时编程开发中常用的技术,而这次我负责开发报表模块所以使用分页很多。

在分页的时候遇到一个问题,用索引主键进行分页,出现了无法跳页的情况,

起初我怀疑表设计的有问题,或者表建立了索引,或者其他什么约束什么的对表的索引造成了影响,没想到是由于id排序因素导致,

在我们用sql查询语言在数据库中提取数据时,提取的项不同,数据库返回数据的顺序也可能会不同。

因为数据库的这种机制所以在使用数据库分页索引的时候必须要对索引的主键id进行排序

select top 10 * from res_hole
where id
not in (select top 10 id from res_hole)

 

如下对索引主键排序:

select top 10 * from res_hole
where id
not in (select top 20 id from res_hole order by id)
order by id

相关文章:

  • 2021-12-25
  • 2022-03-03
  • 2021-12-31
  • 2022-01-14
  • 2021-12-04
  • 2022-12-23
  • 2021-03-27
  • 2021-05-23
猜你喜欢
  • 2021-12-21
  • 2022-12-23
  • 2021-05-22
  • 2021-04-09
相关资源
相似解决方案