Reputation: 343
The thing I would like to do:
Select the row where date = 2012-10-14 and then display 4 rows which go after that row. So from this list
2012-10-12 column #2
2012-10-13 column #2
2012-10-14 was very sunny.
2012-10-15 rained all day.
2012-10-16 whatever.
2012-10-17 column #2
2012-10-18 column #2
2012-10-19 rained all day.
2012-10-20 whatever.
2012-10-21 column #2
2012-10-22 column #2
it would return this:
2012-10-14 was very sunny.
2012-10-15 rained all day.
2012-10-16 whatever.
2012-10-17 column #2
2012-10-18 column #2
Thanks for help.
PS: In the database there are no data on weekends so some of the dates will be missing.
Upvotes: 1
Views: 156
Reputation: 1877
This version is for a date range rather than for a fixed number of rows. It is not completely clear which one you want.
select * from mytable where date_diff(date,'2012-10-14') <= 4 and date >= '2012-10-14';
Upvotes: 1