SELECT * FROM TableName WHERE name='test'
Once the above query is executed I want the previous and next id values. Ofcourse they will not be incremental. How can I get the next and previous ids based on the where condition.
SELECT * FROM TableName WHERE name='test'
Once the above query is executed I want the previous and next id values. Ofcourse they will not be incremental. How can I get the next and previous ids based on the where condition.
try below
select * from Tablename where name = 'test' AND id = (select min(id) from Tablename where id > 4) OR id = (select max(id) from Tablename where id < 4)