create table test_2(TDate date);
insert into test_2 values(now());
select * from test_2;
create table calendar(year int, month int, day int);
insert into calendar select year(tdate) as year,month(tdate) as month, day(tdate) as day from test_2;
mysql> select * from calendar;
+------+-------+------+
| year | month | day |
+------+-------+------+
| 2018 | 5 | 5 |
+------+-------+------+
1 row in set (0.00 sec)
1条答案
按热度按时间bfnvny8b1#
试试这个,我想你在找。它只是一个简单的使用年,月,日函数提取所有这些值并插入到不同的表中,如下所示。