Actions
Feature #17461
closedInclude WITH keyword
Start date:
11.12.2023
Due date:
% Done:
0%
Estimated time:
Discuss:
Prio Planung:
No
Vote:
Description
The WITH keyword signifies a Common Table Expression (CTE). It allows you to refer to a subquery expression many times in a query, as if having a temporary table that only exists for the duration of a query. More
It has yet to be included in QFQ.
Files
Updated by Jan Haller 7 months ago
E.g.:
Result:
WITH RECURSIVE CountNumbers AS (
SELECT 1 AS Number
UNION ALL
SELECT Number + 1
FROM CountNumbers
WHERE Number < 4
)
SELECT Number FROM CountNumbers;
Result:
Number |
1 |
2 |
3 |
4 |
Updated by Jan Haller 7 months ago
WITH enables the possibility to fire subqueries as often as wanted without the need of actual records being selected.
E.g.:
10.sql = SELECT 10 AS _myCount
20 {
sql = WITH RECURSIVE CountNumbers AS (
SELECT 1 AS Number
UNION ALL
SELECT Number + 1
FROM CountNumbers
WHERE Number < '{{myCount:R0}}'
)
SELECT Number FROM CountNumbers
30 {
sql = SELECT '<br>'
}
}
Actions