时间:2021-07-01 10:21:17 帮助过:38人阅读
* 每一个小时为一个分段 生成如下辅助表
INSERT INTO calendar(datehour)
SELECT
DATE_ADD((DATE_FORMAT("2018-11-10", ‘%Y-%m-%d‘)),INTERVAL numlist.id HOUR) AS `date`
FROM (
SELECT n1.i + n10.i * 10 + n100.i * 100 + n1000.i * 1000+ n10000.i * 10000 AS id
FROM num n1
CROSS JOIN num AS n10
CROSS JOIN num AS n100
CROSS JOIN num AS n1000
CROSS JOIN num AS n10000 ) AS numlist;
mysql生成日期的辅助表
标签:ima 方便 rom mat select -- 分段 sts sele