你没提到判断"上一条"和"下一条"的标准,这里就假设id是有序的,并且最Id越大越靠后.
1, 选择相邻的ID:
下一个: select min(id) from table0 where where id > currentId
上一个: select max(id) as prevId from table0 where id < currentId
2, 选择记录:
下一条记录: select * from table0 where id in ( select min(id) from table0 where id > currentId)
上一条记录: select * from table0 where id in (select max(id) from table0 where id < currentId)