CREATE TABLE tblDates ('id' INTEGER PRIMARY KEY AUTOINCREMENT,'stamp' INTEGER);
70|1196420400
71|1196679600
72|1196766000
73|1196852400
74|1196938800
75|1197025200
76|1197284400
77|1197370800
78|1197457200
79|1197543600
81|1197630000
Is it possible to fetch id's 75, 76 and 77 if all I know is the stamp value of id 76?
Basically I need some SQL that pulls three rows based on a known stamp value plus the nearest higher stamp value and the nearest lower stamp value. It's entirely possible that id 82 could contain a stamp value that is lower than that of id 81.
This is my current solution (assuming id=75):
sqlite> select id from tbldates where stamp<(select stamp from tbldates where id=75) order by stamp desc limit 1;
74
sqlite> select id from tbldates where stamp>(select stamp from tbldates where id=75) limit 1;
76