您好,登錄后才能下訂單哦!
select ... from <TableName>
where <Conditional-1>
start with <Conditional-2>
connect by <Conditional-3>;
//<Conditional-1>:過濾條件,用于對(duì)返回的所有記錄進(jìn)行過濾。
//<Conditional-2>:查詢結(jié)果重起始根結(jié)點(diǎn)的限定條件。
//<Conditional-3>:連接條件
//如果connect by prior中的prior被省略,則查詢將不進(jìn)行深層遞歸。
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 = '系統(tǒng)功能' 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'
向上遞歸和向下遞歸的關(guān)鍵就是最后一個(gè)條件,父ID等于ID則向上遞歸,反之向下遞歸。
參考:http://www.cnblogs.com/wanghonghu/archive/2012/08/31/2665945.html
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。