在sqlite中选择范围(1到100)之间的数字 [英] Select numbers between a range (1 to 100) in sqlite
本文介绍了在sqlite中选择范围(1到100)之间的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道 SQL 中的一些解决方案,但在 SQlite 中找不到任何解决方案.
I know some of the solutions in SQL but couldn't find any of them from SQlite.
我只想执行一个选择查询,该查询返回一个从 1 到 100 的数字结果集.
I just want to execute a select query that returns a resultset of numbers ranging from 1 to 100.
Numbers
1
2
3
4
......
5
更正:我实际上根本没有桌子.(但是鼓励使用像 MySQL 中的 dual
这样的虚拟表的解决方案)
A correction: I don't actually have a table at all. (however a solution is encouraged with a virtual table like dual
in MySQL)
推荐答案
感谢 sgmentzer!受到您的回答的启发,我继续前进,还发现了this:
Thanks sgmentzer! Inspired by your answer I went ahead and also found this:
WITH RECURSIVE
cnt(x) AS (
SELECT 1
UNION ALL
SELECT x+1 FROM cnt
LIMIT 100000
)
SELECT x FROM cnt;
这篇关于在sqlite中选择范围(1到100)之间的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文