---
title: "oracle递归加多表连接查询"
author: "bolan392"
date: "2011-07-20T17:49:14Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2011-07-20T17:49:14Z"
id: 1129079
url: "https://bolan392.iteye.com/blog/1129079"
---

写了一段Oracle的递归查询结合多表连接查询的SQL，记录下来，备忘

 

```
 select a.ar_file_name,a.ar_depart_id,b.depart_no,b.depart_name
 from t_archives a left join csr_department b on(a.ar_depart_id = b.depart_no)
 where a.ar_depart_id in(
 	select a.depart_no
           from csr_department a 
          start with a.depart_no in ('8637')
         connect by prior a.depart_id = a.parent_id
 )
```

 

t\_archives 表：中存放了所有分支结构的档案文件

 

csr\_department表 ：存放所有机构的表

 

查询要求，各机构可以查询本机构及下属机构的档案，所有需要使用oracle的递归查询