1. 程式人生 > >Mysql實現文章查詢上一篇和下一篇功能,附sql語句?

Mysql實現文章查詢上一篇和下一篇功能,附sql語句?

mysql實現文章查詢上一篇和下一篇功能,附sql語句?

Mysql實現文章查詢上一篇和下一篇功能,sql語句:

1 (select * from articles where id < #id# order by id desc limit 1)
2 union all
3 (select * from articles where id > #id# order by id limit 1)

OK,網上大部分都是這麼幹的,效率上的話,包子強烈建議不要 select * 之類的,效率與指定的幾個欄位效率有點區別。