gpt4 book ai didi

mysql - 如何获得一个月内的所有星期一?

转载 作者:行者123 更新时间:2023-11-29 02:21:48 24 4
gpt4 key购买 nike

我想获取 2015 年 5 月的所有星期一

(使用mysql查询)

输出:

MON   
04
11
18
25

最佳答案

select row+1  as Mon from   
( SELECT @row := @row + 1 as row FROM
(select 0 union all select 1 union all select 3 union all select 4 union all select 5 union all select 6) t1,
(select 0 union all select 1 union all select 3 union all select 4 union all select 5 union all select 6) t2,
(SELECT @row:=-1) t3 limit 31 ) b where
DATE_ADD('2015-05-01', INTERVAL ROW DAY) between '2015-05-01' and '2015-05-31' and DAYOFWEEK(DATE_ADD('2015-05-01', INTERVAL ROW DAY))=2;

输出

+------------+
| Mon |
+------------+
| 4 |
| 11 |
| 18 |
| 25 |
+------------+

稍微调整一下 query

关于mysql - 如何获得一个月内的所有星期一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30448501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com