如何结合递归CTE和普通CTE [英] how to combine recursive CTE and normal CTE
本文介绍了如何结合递归CTE和普通CTE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想先在表上放置普通CTE,然后再递归CTE
I want a first a normal CTE on table and followed by a recursive CTE
我如何将这两者结合在一起?
how can I combine this two?
我知道我可以做多个纯正的CTE
I know for multiple pure normal CTE I can do
WITH CTE1 AS(
), CTE2 AS(),...
所以我已经尝试过
WITH CTE1 AS(
), RECURSIVE CTE2()
但这给了我一个语法错误
but that gives me a syntax error
推荐答案
只需将 recursive
,即使递归的后面出现也是如此:
Just put the recursive
at the start, even if the recursive one comes later:
with recursive cte1 as (
...
), cte2 as (
-- here comes the recursive cte
...
)
select *
from ...
这篇关于如何结合递归CTE和普通CTE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文