Mysql 根据年月遍历当前月份得每一天

select CONCAT('2020-02','-',help_topic_id +1)  day,help_topic_id,day(last_day( CONCAT('2020-02','-1'))) as dayT
from mysql.help_topic
where help_topic_id  < day(last_day(CONCAT('2020-02','-1')))
order by help_topic_id

在这里插入图片描述

其中'2020-02'是传入得值,last_day( CONCAT('2020-02','-1'))是查询当月最后一天
day(last_day( CONCAT('2020-02','-1')))是获取当前月份一共有多少天

猜你喜欢

转载自blog.csdn.net/zhongzih/article/details/105999597
今日推荐