MySQL显示范围之间的所有日期

MySQL显示范围之间的所有日期,第1张

MySQL显示范围之间的所有日期

您可以使用以下命令生成日期列表:

select a.Date,  s.*from (  select curdate() + INTERVAL (a.a + (10 * b.a) + (100 * c.a)) DAY as Date  from (select 0 as a 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 a  cross join (select 0 as a 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 b  cross join (select 0 as a 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 c) ainner join schedule s  on a.Date >= s.fromDate   and a.Date <= s.toDate

参见带有演示的SQL Fiddle



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5063036.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存