I simply need to return a list of all days within a month. I\'m not accessing a specific table. So I need a sql select statement if given the month of February, return the
I agree with the comments, that something like this shouldn't be done in the database, but technically its possible. If you give the start and end date, adding additional numbers to the subquery if necessary:
SELECT '2011-02-01' + INTERVAL a + b DAY dte
FROM
(SELECT 0 a UNION SELECT 1 a UNION SELECT 2 UNION SELECT 3
UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7
UNION SELECT 8 UNION SELECT 9 ) d,
(SELECT 0 b UNION SELECT 10 UNION SELECT 20
UNION SELECT 30 UNION SELECT 40) m
WHERE '2011-02-01' + INTERVAL a + b DAY < '2011-03-01'
ORDER BY a + b
Results:
"2011-02-01"
"2011-02-02"
"2011-02-03"
....
"2011-02-28"