Home  >  Article  >  Backend Development  >  求 下一条记录,该怎么处理

求 下一条记录,该怎么处理

WBOY
WBOYOriginal
2016-06-13 13:48:00753browse

求 下一条记录
我要做一个采集,用跳转的方式。id是一个没有连续的唯一id号
我在跳转的时候,怎么样才能得到它的下一条数据呢????


我的初始想法是这样的。

求出数据库里的 最小 最大 id 
然后在采集的时候,用循环id加1方法遍历所有数据。

但是这里有一个问题,因为id不连续, 在采的时候,肯定有空的数据。

我想问问大哥们,你们有没有好的办法呢。

------解决方案--------------------
比当前ID大 根据ID排序 升序 取一条
------解决方案--------------------
大于上一个id 升序 LIMIT 1
------解决方案--------------------
1.既然是采集别人的站,看看他们有没有列表页,有的话,按他们的列表逐个采就是了。

2.可以从小ID一直累加,判断打开的页是否是正常页,或者404页什么的。
------解决方案--------------------
肯定有索引嘛...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn