Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
postgresql中的cte与ms sql_Sql_Sql Server_Postgresql_Tsql_Common Table Expression - Fatal编程技术网

postgresql中的cte与ms sql

postgresql中的cte与ms sql,sql,sql-server,postgresql,tsql,common-table-expression,Sql,Sql Server,Postgresql,Tsql,Common Table Expression,我的观察是,我们不能在postgresql中的嵌套cte案例中混合cte和递归cte,但看起来我们可以在MS SQL中这样做。我说得对吗?例如,对于postgresql,在这种情况下我将得到错误 with cte1 ( ... ), recursive cte2 (...) select * from cte1 join cte2; 但看起来它适用于ms sql。这是否正确?两个数据库都支持混合使用非递归和递归公共表表达式 在Postgres中,语法为: with recursive

我的观察是,我们不能在postgresql中的嵌套cte案例中混合cte和递归cte,但看起来我们可以在MS SQL中这样做。我说得对吗?例如,对于postgresql,在这种情况下我将得到错误

with cte1 ( ... ),
recursive cte2 (...)
select * from cte1 join cte2;

但看起来它适用于ms sql。这是否正确?

两个数据库都支持混合使用非递归和递归公共表表达式

在Postgres中,语法为:

with recursive
    cte1 as (...), -- non-recursive CTE
    cte2 as (...)  -- recursive CTE
select * from cte1 join cte2
SQL Server无法识别
recursive
关键字,因此:

with 
    cte1 as (...), -- non-recursive CTE
    cte2 as (...)  -- recursive CTE
select * from cte1 join cte2

这两个数据库都支持混合使用非递归和递归公共表表达式

在Postgres中,语法为:

with recursive
    cte1 as (...), -- non-recursive CTE
    cte2 as (...)  -- recursive CTE
select * from cte1 join cte2
SQL Server无法识别
recursive
关键字,因此:

with 
    cte1 as (...), -- non-recursive CTE
    cte2 as (...)  -- recursive CTE
select * from cte1 join cte2

只需将
recursive
关键字放在第一个CTE之前。它适用于整个
with
子句。只需将
recursive
关键字放在第一个CTE之前。它适用于整个
with
子句。