Referencing the query_name more than once in the query definition:
WITH RECURSIVE query_name (c) AS (
VALUES (1)
UNION
SELECT x FROM query_name JOIN base_table
ON base_table.x = query_name.c
UNION
SELECT y FROM query_name JOIN base_table
ON base_table.y = query_name.c
)
SELECT *
FROM query_nameRelated
Tutorial:
With— Organize Complex QueriesOther forms:
cycle … set … to … default … using,with,with recursive,within subquery,with recursivein subquery.Product specific forms:
connect by.
Normative References
The with recursive clause is defined in ISO/IEC 9075-2:2023 §7.17 as part of optional feature T131, “Recursive query” but non-linear recursion is prohibited in ISO/IEC 9075-2:2023 §7.17 SR 3jx.

