I need a table to store all the working days. I dont like loop, so I tried sql. The following is the SQL I used.
insert into tb_working_days(data_date,day_type)
select DATE_ADD(data_date,INTERVAL (select count(1) from tb_working_days) day),"W"
from tb_working_days ;
At first, I insert one date into the table.
Then I run this sql once, I get two rows. Run once more, I get four rows, as so on.
after 10 runs, I get more than 1000 rows. the work is done.
The most interesting point is the sql after Interval, and it makes the magic. The db is smart enough to convert a set into a int. that is amazing.