文章列表有上下篇文章功能。(求一例子或者思路)谢谢!

我用select top 1 from xx where id>xx   select top 1 from xx where id>xx

得到该文章的上下篇

但是不知道怎么在页面里做。


海绵宝宝撒
浏览 519回答 2
2回答

慕哥6287543

这条sql语句可以得到两条相邻数据,然后分别显示这两条就ok了select * from Article where &nbsp;([ID] = (select MAX([ID]) from Article where [ID]<当前文章ID号)or [ID] = (select MIN([ID]) from Article where [ID]>当前文章ID号 ))或者select&nbsp;top&nbsp;1&nbsp;*&nbsp;from&nbsp;Article&nbsp;where&nbsp;ID<当前文章ID号&nbsp;order&nbsp;by&nbsp;ID&nbsp;desc;select&nbsp;top&nbsp;1&nbsp;*&nbsp;from&nbsp;Article&nbsp;where&nbsp;ID>当前文章ID号&nbsp;order&nbsp;by&nbsp;ID&nbsp;asc;

有只小跳蛙

你这不是查出两条记录了吗,显示在页面里就可以了。
打开App,查看更多内容
随时随地看视频慕课网APP