set @i = -1;
set @sql = repeat(" select 1 union all",-datediff('2021-01-01','2030-12-31')+1);
set @sql = left(@sql,length(@sql)-length(" union all"));
set @sql = concat("select date_add('2021-01-01',interval @i:=@i+1 day) as date from (",@sql,") as tmp");
prepare stmt from @sql;
execute stmt
比如说我想拼接成这个样子,怎么拼接啊
select * from (select date_add('2012-09-01',interval @i:=@i+1 day) as date
from ( select 1 union all select 1 union all select 1 union all select 1 union all select 1) as tmp,
(select @i:= -1) t) a