Hi, I have a table with rows identifed with various unique ids. How do I, if I know the current id value, select the two rows before and the two rows after the row in question?
What i've got so far is something like this:
$lower = $id - 2;
$upper = $id + 2;
$query = "SELECT * FROM photos WHERE id<='$lower' AND id>= '$upper'"
But this won't work for me because there might be missing IDs. For example, in the situation where the IDs are like so (if i were starting with 5):
2
3
5
9
10
and I'd want all five of thsoe IDs selected, the query above would only select 3 and 5. 🙁
TIA