oracle递归

使用java去写一个递归遍历也不是太难,但是oracle sql里面却有更加简单的方法去实现。
例如:通过组别id递归查询组别下的所有员工

select * from (select * 
	from t_common_group t
	start with t.id = '001'
	CONNECT BY PRIOR t.id=t.parent_id) t2
	join t_common_agent t3 on t2.id = t3.group_id
where t3.state = 'INSERVICE' and t2.enable_flag='Y'

首先通过组别id用CONNECT关联父级id去遍历所有的组别,然后关联员工表获取该组别下的所有员工

posted @ 2014-10-17 09:04  空谷@幽兰  阅读(167)  评论(0编辑  收藏  举报