/* 方式1: 获取给出id 的上一条,下一条 */
select * from t_article where id = (select id from t_article where id < 4 order by id desc limit 1);
select * from t_article where id = (select id from t_article where id > 4 order by id asc limit 1);
/* 方式2: 获取给出id 的上一条,下一条 */
select * from t_article where id = (select max(id) from t_article where id < 4);
select * from t_article where id = (select min(id) from t_article where id > 4);
MySQL----查询文章(数据库)的上一条,下一条
最新推荐文章于 2023-04-22 22:50:08 发布