常用SQL

来自牛奶河Wiki
跳到导航 跳到搜索

MySQL

生成连续数字

with recursive seq(no) as(
    select   1  no
    union all
    select   no+1  no
    from     seq
    where    no < 100
)
select   no
from     seq
;

固定长度数字

select substr(concat('00000', cast(rand() * 1000000 as int)), -6, 6)

近一百天内时间

select subdate(now(), cast(rand() * 100 as int))