当前ID为234,下面两个语句可以选出上一篇,下一篇,我想要把他合成一个查询语句可以吗。应该怎么做
select top 1 * from emailRC where id>234 order by id
select top 1 * from emailRC where id<234 order by id desc
查询出来的结果如
preID nextID
231 248
------解决方案--------------------
- SQL code
select min(id) from emailRC where id>234 Union select max(id) from emailRC where id<234