常用sql

本月的所有日期。 找一个id有1~31的表
SELECT
DATE_FORMAT(
date_add(
last_day(curdate()),
INTERVAL (
cast(
help_topic_id AS signed INTEGER
) - DAY (last_day(curdate()))
) + 1 DAY
),
'%Y-%m-%d'
) DAY
FROM
mysql.help_topic
WHERE
help_topic_id < DAY (last_day(curdate())) ORDER by help_topic_id ;

posted @ 2023-08-01 16:41  梧桐将秋色  阅读(5)  评论(0编辑  收藏  举报