`
bolan392
  • 浏览: 273712 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

oracle递归加多表连接查询

 
阅读更多

写了一段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的递归查询

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics