Select a row and rows around it

后端 未结 7 2176
庸人自扰
庸人自扰 2020-12-19 15:05

Ok, let\'s say I have a table with photos.

What I want to do is on a page display the photo based on the id in the URI. Bellow the photo I want to have 10 thumbnails

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 15:41

    I don't believe that you can have an "order by" in different sections of a UNION. Could you just do something like this:

    SELECT * FROM media where id >= 7 - 4 and id <= 7 + 4 ORDER BY id
    

提交回复
热议问题