關(guān)系表:sys_function
id :主鍵id
pid:父關(guān)系id
Oracle函數(shù):start with…connect by…prior
1.表數(shù)據(jù)
select * from family;
2.查詢自己和自己所有的后代
select s.*
from family s
start with s.id = 'me'
connect by prior s.id = s.pid;
3.查詢自己和自己的祖先
select s.*
from family s
start with s.id = 'me'
connect by s.id = prior s.pid;
4.查詢自己所有的后代(不包括自己)
select s.*
from family s
start with s.pid = 'me'
connect by prior s.id = s.pid;
5.查詢自己的第一代孩子和祖先(包括自己)
select s.*
from family s
start with s.pid = 'me'
connect by s.id = prior s.pid;