You can use the concept, which is often referred to as "calendar tables." Here is a good guide to creating calendar tables in MySql:
-- create some infrastructure CREATE TABLE ints (i INTEGER); INSERT INTO ints VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9); -- only works for 100 days, add more ints joins for more SELECT cal.date, tbl.data FROM ( SELECT '2009-06-25' + INTERVAL ai * 10 + bi DAY as date FROM ints a JOIN ints b ORDER BY ai * 10 + bi ) cal LEFT JOIN tbl ON cal.date = tbl.date WHERE cal.date BETWEEN '2009-06-25' AND '2009-07-01';
You might want to create a cal table instead of a subquery.
Josef Pfleger Jul 03 '09 at 17:59 2009-07-03 17:59
source share