MYSQL实现上一篇下一篇文章的sql语句

NOCO发布于 分类 Mysql

19小时前 有1个用户阅读过

MYSQL语句如下示例

(select *,'上一篇' as type from table where id>$id order by id asc limit 1) 
union
(select *,'下一篇' as type from table where id<$id order by id desc limit 1)

推荐将*号设置为指定字段,效率会高一些。seonoco.com就是这样在每篇文章的后面增加了一个模块,显示上一篇和下一篇文章标题和链接。

-- The End --

本文标题: MYSQL实现上一篇下一篇文章的sql语句

本文地址: https://seonoco.com/blog/next-previous-record-in-mysql

本文是否有所帮助?
点赞 0
感谢支持
0
多谢反馈
评论 0
打赏

支持微信/支付宝

评论

网友