first, create a numbers table --
Code:
CREATE TABLE numbers ( n INTEGER NOT NULL PRIMARY KEY );
INSERT INTO numbers ( n ) VALUES
(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)...
then just select from this table as follows...
Code:
SELECT DATE('2013-02-01')
+ INTERVAL n DAY AS the_date
FROM numbers
WHERE DATE('2013-02-01') + INTERVAL n DAY
< DATE('2013-03-01')
now you can use this "on the fly" table as the left table in a LEFT OUTER JOIN to your data table
any dates that are not matched in your data table will generate a NULL
Bookmarks