I used the solution provided here - however, I chose to turn the query given into a VIEW
- which is far superior to actually creating a physical table of dates!
However, I was told by MySQL that you can't have a subquery in the 'FROM' clause
, so my solution is not completely elegant, but perhaps the "10 list" could be useful for other applications. Here's my solution:
First create this view:
CREATE OR REPLACE VIEW `_v_list_10` AS
SELECT 0 AS `a` union all select 1 AS `1` union all select 2 AS `2` union all select 3 AS `3` union all select 4 AS `4`
union all select 5 AS `5` union all select 6 AS `6` union all select 7 AS `7` union all select 8 AS `8` union all select 9 AS `9`;
Then create this view:
CREATE OR REPLACE VIEW _v_dates_1000 AS
SELECT CURDATE() + INTERVAL 365 DAY - INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY AS Date
FROM _v_list_10 AS a
CROSS JOIN _v_list_10 AS b
CROSS JOIN _v_list_10 AS c
NOTE that my date range starts 365 days in the future, and goes back a thousand from there. You could easily build it to 10,000 or 100,000 or etc.
As I have an information database that solely contains near-constant things like state and country names, US counties, etc., this was a good candidate for that database. And, it takes NO SPACE. Hope this helps someone else out!