I'm learning about recursive functions, Since I need to extract a row for each day in a range of days. This is my current data
+----+------------+------------+
| id | from | to |
+----+------------+------------+
| 1 | 09-20-2019 | 09-25-2019 |
+----+------------+------------+
The goal is to receive my data as follows
+----+------------+
| id | date |
+----+------------+
| 1 | 09-20-2019 |
| 1 | 09-21-2019 |
| 1 | 09-22-2019 |
| 1 | 09-23-2019 |
| 1 | 09-24-2019 |
| 1 | 09-25-2019 |
+----+------------+
I'm following an example seen here: https://stackoverflow.com/a/54538866/1731057 But for some reason my recursive function is looking for the 'cte' table.
Query 1 ERROR: Table 'project.cte' doesn't exist
WITH cte AS (
SELECT date_from
FROM event_dates
UNION ALL
SELECT DATE_ADD(event_dates.date_from, INTERVAL 1 DAY)
FROM cte
WHERE DATE_ADD(event_dates.date_from, INTERVAL 1 DAY) <= event_dates.date_until
)
select * FROM cte;