例如:
Select * From (
WITH RECURSIVE cte_name AS (
initial_query -- anchor member
UNION ALL
recursive_query -- recursive member that references to the CTE name
)
SELECT * FROM cte_name
) A
答案 0 :(得分:0)
处理WITH syntax for Common Table Expressions的MySql 8.0参考手册的13.2.13节提到以下内容:
在以下情况下允许WITH子句: 在子查询(包括派生表子查询)的开头:
SELECT ... WHERE id IN (WITH ... SELECT ...) ... SELECT * FROM (WITH ... SELECT ...) AS dt ...
因此,这澄清了我的问题,因此将我自己的答案作为社区Wiki。