Let's assume that in database are these values:
time_column
2013-03-02 19:00:00
2013-03-02 20:00:00
2013-03-02 21:00:00
2013-03-02 22:00:00
I need to get the last 3 records include with the value from a row, which is in the query.
SELECT * FROM table WHERE time_column =< '2013-03-02 22:00:00' LIMIT 3
This query returns these rows (no 22:00:00):
2013-03-02 19:00:00
2013-03-02 20:00:00
2013-03-02 21:00:00
But I need to get these ones:
2013-03-02 20:00:00
2013-03-02 21:00:00
2013-03-02 22:00:00
But how to do that?
Thank you
EDIT: There is a way to get the needed rows on the application layer, but if would be possible to get that from a sql, that would be great.