I have mysql table with the following structure. All records are static and only for read, and had been imported from CSV so all year, month, day are in correct sequence as per I created them. (No, ID column in this table because I only access data by year, month and day)
mysql table 'daily'
year month day data
1990 01 01 xxxxxxxxxxxxx
1990 01 02 eeeeeeeeeeeee
1990 01 03 rrrrrrrrrrrrr
1990 01 04 ttttttttttttt
.
.
.
Now, I can access the records by simple select statement as below
select * where year=1990 and month=1 and day=03 limit 1
But how can I select the query row + 3 or any number of adjacent rows (before or after the query row)? And I don’t want to use ID if there is better solutions.
I would consider using the
DATEtype instead of separate columns for year, month, and day. Then you can useDATEADDand related functions to find the day you want.http://dev.mysql.com/doc/refman/5.1/en/datetime.html
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html