2010年9月23日 星期四

oracle 樹狀資料查詢命令

從根節點往子節點查詢
select level,m_id,id from table
start with mid='x'
connect by prior id = m_id

從子節點往根節點查詢
select level,m_id,id from table
start with id='x'
connect by prior m_id = id

REF:
http://www.adp-gmbh.ch/ora/sql/connect_by.html

沒有留言: