SQL_之 递归_START WITH id ='102' CONNECT BY PRIOR pid=id
oracle 递归用法
SELECT * FROM menu START WITH id ='102' CONNECT BY PRIOR pid=id
一种应用
SELECT * FROM menu a START WITH id in (select menu_id from role_menu where role_code = '005') CONNECT BY PRIOR id = pid)
解释:不太明白为什么,
这个时候查出来的数据是重复的
SELECT a.id FROM menu a START WITH id in (select id from menu) CONNECT BY PRIOR id = pid
查出来的数据还是重复的.
select * from menu where id in (SELECT a.id FROM menu a START WITH id in (select menu_id from role_menu where role_code = '005') CONNECT BY PRIOR id = pid)