table t(a,b,c,d,e,f,g)
a,e--区域ID
b,f--分店ID
c,g--员工ID
a,b,c--下属员工
e,f,g--上司
哎,你的表怎么這么混亂呢?
到sql reference里面看connect by語句的用法。
a,e--区域ID
b,f--分店ID
c,g--员工ID
a,b,c--下属员工
e,f,g--上司
哎,你的表怎么這么混亂呢?
到sql reference里面看connect by語句的用法。
调试欢乐多
create table TEST_TREE
(
ID VARCHAR2(8),
NAME VARCHAR2(1024),
PID VARCHAR2(8),
SCORE NUMBER,
BZ VARCHAR2(1024)
)
tablespace SKST_DATA
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 128K
next 128K
minextents 1
maxextents unlimited
pctincrease 1
);select * from test_tree start with ID=2 connect by PRIOR ID=PID;
t1.A & t1.E
, t1.B & t1.F
, t1.C & t1.G
from T t1
where t1.E & t1.F & t1.G
In
select t2.E & t2.F & t2.G
from T t2
where
t2.A & t2.E = '****'
and t2.B & t2.F = '****'
and t2.C & t2.G = '****'
;不知这样可不可行
http://expert.csdn.net/Expert/topic/1551/1551178.xml?temp=.3549311
select A||B||C||D as 唯一确定的员工,
A||E as 员工的区域ID,
B||F as 工作的分店ID,
C||G as 员工的ID,
from table
connect by E||F||G=prior A||B||C
start with A||B||C||D='某一个确定的员工'
查询上司:
select A||B||C||D as 唯一确定的员工,
A||E as 员工的区域ID,
B||F as 工作的分店ID,
C||G as 员工的ID,
from table
connect by A||B||C=prior E||F||G
start with A||B||C||D='某一个确定的员工'然后将两个查询Union起来即可