gpt4 book ai didi

mysql - 是否有可能在 mysql 中创建选择系列?

转载 作者:行者123 更新时间:2023-11-28 23:36:05 25 4
gpt4 key购买 nike

是否可以在 SQL 中选择数字系列或日期系列?比如创建一个包含 N 行的表,例如 1 到 10:

1
2
3
...
10

2010-01-01  
2010-02-01
...
2010-12-01

最佳答案

如果安装 common_schema ,您可以使用 numbers 表轻松创建查询以输出这些类型的范围。

例如,这 2 个查询将根据您的示例生成输出:

select n 
from common_schema.numbers
where n between 1 and 10
order by n

select ('2010-01-01' + interval n month)
from common_schema.numbers
where n between 0 and 11
order by n

关于mysql - 是否有可能在 mysql 中创建选择系列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35710551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com