转自:https://hacpai.com/article/1558144768869
oracle
SELECT TO_DATE(TO_CHAR(SYSDATE, 'YYYYMM'), 'YYYYMM') + (ROWNUM - 1) DAY_ID
FROM DUAL
CONNECT BY ROWNUM <=
TO_NUMBER(TO_CHAR(LAST_DAY(TO_DATE(TO_CHAR(SYSDATE, 'YYYYMM'),
'YYYYMM')),
'DD'))
mysql
SELECT
DATE_ADD(CURDATE(),INTERVAL(CAST(help_topic_id AS SIGNED INTEGER)-(DAYOFMONTH(CURDATE())-1)) DAY) DAY
FROM mysql.help_topic
WHERE help_topic_id < DAY(LAST_DAY(CURDATE()))
ORDER BY help_topic_id
注:help_topic 为 mysql 存储内置函数的表