在我们查看一篇文章的时候会在文章的底部有2条新闻是本条新闻的上一条和下一条,SQL是如何实现呢?
select * from news where id>4 order by id asc limit 1;
select * from news where id=4 limit 1;
select * from news where id<4 order by id desc limit 1;
很简单吧!!!
在我们查看一篇文章的时候会在文章的底部有2条新闻是本条新闻的上一条和下一条,SQL是如何实现呢?
select * from news where id>4 order by id asc limit 1;
select * from news where id=4 limit 1;
select * from news where id<4 order by id desc limit 1;
很简单吧!!!