add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE test (id INT, start_date DATE, end_date DATE, frequency INT);
INSERT INTO test VALUES
(1, '2020-11-23', '2021-06-21', 1),
(2, '2020-11-19', '2021-03-20', 2);
Records: 2  Duplicates: 0  Warnings: 0
WITH RECURSIVE
cte AS ( SELECT id, start_date, end_date, frequency
FROM test
UNION ALL
SELECT id, start_date + INTERVAL frequency MONTH, end_date, frequency
FROM cte
WHERE start_date <= end_date )
SELECT id, start_date `date`
FROM cte
WHERE start_date <= end_date
ORDER BY 1,2
id date
1 2020-11-23
1 2020-12-23
1 2021-01-23
1 2021-02-23
1 2021-03-23
1 2021-04-23
1 2021-05-23
2 2020-11-19
2 2021-01-19
2 2021-03-19