Notes on using recursive Common Table Expressions (CTEs):
WITH RECURSIVE
must contain a compound SELECT
UNION ALL
performs better than UNION
— The WITH Clause, SQLite documentation
WITH RECURSIVE seq(n) AS ( VALUES(1) UNION ALL SELECT n + 1 FROM seq LIMIT 10 ) SELECT * FROM seq;
n |
---|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |