-- 最近30天
select date_add(curdate(), interval(cast(help_topic_id as signed integer) - 30) day) day
from mysql.help_topic
where help_topic_id <= day(last_day(curdate()))
order by help_topic_id
-- 最近7天
select date_add(curdate(), interval(cast(help_topic_id as signed integer) - 6) day) day
from mysql.help_topic
where help_topic_id <= 6
order by help_topic_id
-- 一年内的每个月
select mid(date_add(curdate(), interval(cast(help_topic_id as signed integer) - 11) day) ,1,7) day
from mysql.help_topic
where help_topic_id <= 11
order by help_topic_id
标签:语句,help,查询,topic,select,mysql,id,day From: https://blog.51cto.com/momo1226/9331189