繁体   English   中英

如果我有一个ID,怎么知道在哪个页码中?

[英]If I have the an id how to know in which page number?

数据库中的表

id

1  
2   
4  
30  
31
...

分页

per page is 2 row, desc.   

如果我的id = 30怎么知道在哪个页码中? 任何建议将不胜感激

首先获得其订单:

select count(*) from table_name where id <= 30 order by col_name;

然后图页码:

int order = 27; // the result from previous query,
int pageSize = 10;
int pageNum = order/pageSize + (order%pageSize==0?0:1); // here page number start from 1, not 0,

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM