Revision: 70280
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 3, 2016 13:15 by ktrout
Initial Code
drop table if exists calendar_t; CREATE TABLE calendar_t ( id integer primary key auto_increment not null, `date` date not null, day varchar(9) not null, month varchar(13) not null, `year` integer not null ); drop view if exists digits_v; create view digits_v as select 0 as n 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 ; insert into calendar_t ( `date`, day, month, `year` ) select date_add('2015-01-01', interval 100*a2.n + 10*a1.n + a0.n day) as `date`, dayname(date_add('2015-01-01', interval 100*a2.n + 10*a1.n + a0.n day)) as day, monthname(date_add('2015-01-01', interval 100*a2.n + 10*a1.n + a0.n day)) as month, year(date_add('2015-01-01', interval 100*a2.n + 10*a1.n + a0.n day)) as `year` from digits_v a2 cross join digits_v a1 cross join digits_v a0 order by date_add('2015-01-01', interval 100*a2.n + 10*a1.n + a0.n day) ;
Initial URL
Initial Description
creates a minimal calendar table
Initial Title
mysql calendar table
Initial Tags
mysql
Initial Language
SQL