mysql 获取任意一个月的所有天数。
Posted 段桥123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 获取任意一个月的所有天数。相关的知识,希望对你有一定的参考价值。
SELECT ADDDATE(y.first, x.d - 1) as d
FROM
(
SELECT 1 AS d 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 UNION ALL
SELECT 10 UNION ALL
SELECT 11 UNION ALL
SELECT 12 UNION ALL
SELECT 13 UNION ALL
SELECT 14 UNION ALL
SELECT 15 UNION ALL
SELECT 16 UNION ALL
SELECT 17 UNION ALL
SELECT 18 UNION ALL
SELECT 19 UNION ALL
SELECT 20 UNION ALL
SELECT 21 UNION ALL
SELECT 22 UNION ALL
SELECT 23 UNION ALL
SELECT 24 UNION ALL
SELECT 25 UNION ALL
SELECT 26 UNION ALL
SELECT 27 UNION ALL
SELECT 28 UNION ALL
SELECT 29 UNION ALL
SELECT 30 UNION ALL
SELECT 31
) x,
(
SELECT ‘2018-04-05‘ - INTERVAL DAY(‘2018-04-05‘) - 1 DAY AS first,
DAY(LAST_DAY(‘2018-04-05‘)) AS last) y
WHERE x.d <= y.last
以上是关于mysql 获取任意一个月的所有天数。的主要内容,如果未能解决你的问题,请参考以下文章