Mysql traverses each day of the current month according to the year and month

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

Insert picture description here

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

Guess you like

Origin blog.csdn.net/zhongzih/article/details/105999597