WITH RECURSIVE作为查询中的第二部分CTE。 Postgres的

时间:2017-12-26 12:55:07

标签: postgresql common-table-expression recursive-query

我如何编写这样的查询:

with t1 as 
(
select id 
from table1
),
RECURSIVE t2(
select * from t2
union
...
)

目前不允许这样做?

1 个答案:

答案 0 :(得分:0)

recursive需要在WITH之后,无论您放置递归CTE的位置如何:

with recursive t1 as 
(
  select id 
  from table1
), t2 (
  select *  
  from t2
  union
  ...
)
...