MYSQL取出某条记录的前一条和后一条的记录,该怎么解决

WBOY
Release: 2016-06-13 13:52:56
Original
1392 people have browsed it

MYSQL取出某条记录的前一条和后一条的记录
MYSQL取出某条记录的前一条和后一条的记录?如何写?谢谢!

------解决方案--------------------
……

这个……用sql语句。

php中MySQl没有像ASP中的recordset一样的东西的存在,所以,只能使用SQL了。也就是说,按照你的读取的顺序,一次读取三条信息,第一条为上一个的ID,第三个为下一个的ID,第二个为所读取的ID。这么看来,好像就解决了问题……把这几个东西全部放到一个数组里面(也可以一次读取所有的信息的ID,但是,如果数据链非常巨大,就有点问题。如果加上limit的限制,那么就可以了~不过还是有问题……问题真的好多……在翻页的时候……这个好像是不成还的……)

过几天在想办法吧~最近比较忙
------解决方案--------------------
SELECT * FROM `softinfo` WHERE info_id> 20-2 AND info_id 20 LIMIT 0, 2 只有有递增段才可以这么做!
------解决方案--------------------
..........你想得太多了,试试不知道了!
------解决方案--------------------
哦,对,我再想想
------解决方案--------------------
(SELECT * FROM `softinfo` WHERE info_id 20 limit 0, 1) 这样应该行了吧,暂时想不出更好的了.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!