您好,登錄后才能下訂單哦!
select ... from <TableName>
where <Conditional-1>
start with <Conditional-2>
connect by <Conditional-3>;
//<Conditional-1>:過濾條件,用于對返回的所有記錄進行過濾。
//<Conditional-2>:查詢結果重起始根結點的限定條件。
//<Conditional-3>:連接條件
//如果connect by prior中的prior被省略,則查詢將不進行深層遞歸。
select t.* from s_menu t start with t.id='510' connect by prior t.fid = t.id
select t.* from s_menu t start with t.id='510' connect by prior t.fid = t.id
select t.* from s_menu t start with t.id='001' connect by prior t.id = t.fid
select t.* from s_menu t start with t.id='001' connect by prior t.id = t.fid
select t.id,t.name,fid,substr(sys_connect_by_path(NAME,'->'),3) menu_path
from s_menu t start with t.name = '系統功能' connect by prior t.id = t.fid order by t.id
select t.id,lpad('|-',(level-1)*4,'|-')||lpad('『',2)||t.name||rpad('』',2) as newname
from s_menu t connect by prior t.id=t.fid start with t.id='-1'
向上遞歸和向下遞歸的關鍵就是最后一個條件,父ID等于ID則向上遞歸,反之向下遞歸。
參考:http://www.cnblogs.com/wanghonghu/archive/2012/08/31/2665945.html
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。