I'm trying to create a time dataset populated with 30 dates by using a WHILE loop. I'm doing it because I don't have the ability to use CTE in mySql 5.7. afterwards I'll emnbedd this dataset in a subquery. So, let's say the time dataset should look like this -
| Date |
|---|
| 29/05/2022 |
| 28/05/2022 |
| 27/05/2022 |
| ... |
| 29/04/2022 |
I tried to right a WHILE loop as writen below but failed to do so.. If, somebody have an idea, it's highly appreciated.
set @i = DATE_ADD(CURRENT_DATE(), DAY -2 INTERVAL)
set @timeset = select CURRENT_DATE()
while @i < CURRENT_DATE() DO
timeset = @timeset
union
select DATE_ADD(@timeset , DAY 1 INTERVAL)
set @i = DATE_ADD(@i, DAY 1 INTERVAL)
end WHILE
thanks!