Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.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 在postgres中通过根等价物连接_Sql_Oracle_Postgresql - Fatal编程技术网

Sql 在postgres中通过根等价物连接

Sql 在postgres中通过根等价物连接,sql,oracle,postgresql,Sql,Oracle,Postgresql,如何在postgres中通过oracle的根查询隐藏connect。 这是一个oracle查询 select fg_id, connect_by_root fg_id as fg_classifier_id from fg start with parent_fg_id is null connect by prior fg_id = parent_fg_id 您将使用一个递归公共表表达式,该表达式通过递归级别“携带”根: with recursive fg_tree as ( sele

如何在postgres中通过oracle的根查询隐藏connect。 这是一个oracle查询

select fg_id, connect_by_root fg_id as fg_classifier_id
from fg
start with parent_fg_id is null
connect by prior fg_id = parent_fg_id 

您将使用一个递归公共表表达式,该表达式通过递归级别“携带”根:

with recursive fg_tree as (
  select fg_id, 
         fg_id as fg_clasifier_id -- <<< this is the "root" 
  from fg
  where parent_fg_id is null -- <<< this is the "start with" part
  union all
  select c.fg_id, 
         p.fg_clasifier_id
  from fg c 
    join fg_tree p on p.fg_id = c.parent_fg_id -- <<< this is the "connect by" part
) 
select *
from fg_tree;
使用递归fg_树作为(
选择fg_id,
FGZID作为FGY-CasiffielyID-@ NEHA:如果它有效,请考虑。