Created
September 29, 2011 05:33
-
-
Save tamura/1250049 to your computer and use it in GitHub Desktop.
テーブルがなくてもmysqlで日付のリストを出すぜ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select adddate('2011-09-01', numlist.id) as `date` from | |
( | |
SELECT | |
n1.i + n10.i*10 +n100.i*100 as id | |
FROM (select 0 as i 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 n1 | |
cross join (select 0 as i 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 n10 | |
cross join (select 0 as i 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 n100 | |
) as numlist | |
where adddate('2011-09-01', numlist.id) <= '2011-10-2' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment