gpt4 book ai didi

mysql - 技术上是否可以将递归 CTE 的结果用作括号内的子查询? (在 MySql 中)

转载 作者:行者123 更新时间:2023-11-30 21:37:31 25 4
gpt4 key购买 nike

例如:

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

最佳答案

处理 WITH syntax for Common Table Expressions 的 MySql 8.0 引用手册第 13.2.13 节, 提到以下内容:

A WITH clause is permitted in these contexts: At the beginning of subqueries (including derived table subqueries):

SELECT ... WHERE id IN (WITH ... SELECT ...) ...
SELECT * FROM (WITH ... SELECT ...) AS dt ...

所以,这澄清了我的问题,因此将我自己的答案作为社区 wiki。

关于mysql - 技术上是否可以将递归 CTE 的结果用作括号内的子查询? (在 MySql 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53226896/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com