The following question was closed due to it being referenced as a question that's been asked before.
It's not the same question as I have a from and to date whereas the linked question is a single date.
Can this be re-opened please?
I have the following code which works great but I would like to list all calendar dates in the "date" columns even if there is no data.
SELECT
a.date, s.*
FROM
(SELECT
SUBDATE(CURDATE(), 1) + INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY AS date
FROM
(SELECT 0 AS A UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) AS a
CROSS JOIN (SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) AS b
CROSS JOIN (SELECT 0 AS a UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) AS c) a
INNER JOIN
bookings s ON a.date >= s.check_in
AND a.date <= s.check_out
WHERE
check_out >= CURDATE()
ORDER BY check_out , check_in ASC;
Can anyone help?
Many thanks,
John