一個簡單的樹查詢

oracle_ace發表於2007-12-14

SQL> select * from treeview;

PARENT     CHILD
---------- ----------
a          b
a          c
a          e
b          b1
b          b2
c          c1
e          e1
e          e3
c          e

9 rows selected.

SQL> select * from treeview start with parent='c' connect by child=parent;

PARENT     CHILD
---------- ----------
c          c1
c          e

SQL> select * from treeview start with parent='c' connect by prior child=parent;

PARENT     CHILD
---------- ----------
c          c1
c          e
e          e1
e          e3

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12361284/viewspace-604/,如需轉載,請註明出處,否則將追究法律責任。

相關文章