so lets say i have a table called data
data
id | date | name
---------------------
1 | 19/8/2010 | John
2 | 19/8/2010 | Mary
3 | 20/8/2010 | Peter
4 | 20/8/2010 | Bert
5 | 20/8/2010 | Ernie
if i do a select statement like this
SELECT * FROM data where date = '20/8/2010';
is it possible to edit this select statement to take the row before it as well. in this case it returns me row number 3 – 5. but is is possible to edit the sqlstatement in any way to select row 2 as well?
Adapting @SteveCav’s solution to
UNIONwith the original query:Test case (tested in sqlite 3):
Result:
This is assuming that by “the row before”, you intend the row with the previous
idvalue.