mysql生成一个连续的时间序列
select date_add('2021-01-01',interval @i:=@i+1 day) as date from ( select 1 union all select 1 union all select 1 union all select 1) as tmp, (select @i:= -1) t
其中,可以看出
select 1 union all select 1 union all select 1 union all select 1
是为了生成一个一列N行的虚拟表,然后由表t与其做笛卡尔积,这样根据N行会生成n行的一个时间序列。
还没有评论,来说两句吧...