MySQL数据库获取2022年1月到2100年1月所有年月的SQL语句 递归查询好像不得行,有别的写法吗 WITH RECURSIVE dates(date) AS ( SELECT '2022-01-01'::date UNION ALL SELECT date + INTERVAL '1 month' FROM dates WHERE date + INTERVAL '1 month' <= '2100-01-01'::date ) SELECT DISTINCT EXTRACT(YEAR FROM date) AS year, EXTRACT(MONTH FROM date) AS month FROM dates; |
最佳回答 |
||||
0
|
|