I'm thinking about what would be the best way to do what I'm trying to accomplish. As the title says, I have a table with missing dates in mysql, like this:
+------------+
| 2015-09-01 |
| 2015-09-03 |
| 2015-09-05 |
| 2015-09-06 |
| 2015-09-07 |
+------------+
I want to select them to assign them another column with a null
value, so if I also wanted to select the missing dates (days 2 and 4 in my case), which are my options? I thought about making a "calendar" table and select both with a left join and using not in
, but that means I'd have to fill it with a TON of dates (in case someone for some reason wants to select data from the year 2500 or 1800, and I don't want that).
I don't like the option of using a calendar table because of performance stuff, but it also brings another question: if I still used a calendar table, and restricted people from selecting dates in the past or in the future (thus freeing me from having to put hundreds of years of margin in case some crazy soul decided to select stuff from there), how could I make the table fill itself so it has a date for the current date without me having to insert the current date manually?
Can a trigger/function run itself everyday and insert the current date there?
Edit: My intention is using the table for chartjs, so it can have "holes" where there's missing data (with null values).