Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/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
Sql server 在SQL Server中模拟Oracle的连接方式。。。在子查询中_Sql Server_Sql Server 2008 - Fatal编程技术网

Sql server 在SQL Server中模拟Oracle的连接方式。。。在子查询中

Sql server 在SQL Server中模拟Oracle的连接方式。。。在子查询中,sql-server,sql-server-2008,Sql Server,Sql Server 2008,这个问题是前一个问题的延伸 由此我知道了如何在SQL Server中执行连接。在Oracle中,您可以在子查询中轻松使用connect by 所以在甲骨文里我能做到 选择*from t1,其中t1.id在select from connect by query中 在SQL server中也可以这样做吗?如何操作?在SQL Server和其他数据库中,您还需要使用表达式,例如: with some_tree as ( select ... union all select

这个问题是前一个问题的延伸

由此我知道了如何在SQL Server中执行连接。在Oracle中,您可以在子查询中轻松使用connect by

所以在甲骨文里我能做到 选择*from t1,其中t1.id在select from connect by query中


在SQL server中也可以这样做吗?如何操作?

在SQL Server和其他数据库中,您还需要使用表达式,例如:

with some_tree as ( 
    select ...
    union all
    select ...
)
select * 
from t1 
where t1.id in (select some_id from some_tree);
由于版本11.2,Oracle也支持递归公共表表达式,因此您可以在两个数据库上使用相同的语法