---
title: "oracle 递归查询"
author: "terryjs"
date: "2016-05-16T11:55:27Z"
tags: []
categories: ["非技术"]
slug: "oracle"
draft: true
lastmod: "2016-05-16T12:12:57Z"
id: 2298481
url: "https://terryjs.iteye.com/blog/2298481"
---

**oracle 递归查询**

 

 

oracle递归查询  
Oracle中start by prior子句用法  
connect by 是结构化查询中用到的，其基本语法是：  
select ... from tablename start with 条件1  
connect by 条件2  
where 条件3;

例：  
select * from table  
start with org\_id = 'HBHqfWGWPy'  
connect by prior org\_id = parent\_id;

 

//没有 where

```
select * from t_user t start with t.employee_no = '1' connect by prior t.id = t.parent_id;
```

 

//有where

```
select * from t_user t where  t.employee_no <> '1' start with t.employee_no = '1' connect by prior t.id = t.parent_id ;
```