I have the following table, named Example
:
id(int 11) //not autoincriment
value (varchar 100)
It has the following rows of data:
0 100
2 150
3 200
6 250
7 300
Note that id values are not contiguous.
I've written this SQL so far:
SELECT * FROM Example WHERE id = 3
However, I don't know how to get the value of previous id
and value of the next id
...
Please help me get previous value and next value if id
= 3 ?
P.S.: in my example it will be: previous - 150
, next - 250
.
id
and value for nextid
.