答案 0 :(得分:0)
;WITH CTE AS (
SELECT Supervisor
FROM t
WHERE Person='Bob'
UNION ALL
SELECT tt.Supervisor
FROM t tt
INNER JOIN CTE ON CTE.Supervisor = tt.Person
)
SELECT *
FROM CTE
答案 1 :(得分:0)
试试这个:
DECLARE @T TABLE (Person NVARCHAR(30) , Supervisor NVARCHAR(30));
INSERT INTO @T VALUES
('Bob','Alice'),('Mary','Susan'),('Alice','David'),('David','Mary');
select T.Supervisor
from @T T
Where T.Person = 'Bob'
union all
Select TT.Supervisor
From @T TT inner join @T A
on A.Supervisor = TT.Person
答案 2 :(得分:0)
1 =选择主管 来自emp-super 其中person ='bob';
2 =选择主管
来自emp-super
人=
(选择主管
来自emp-super
其中person ='bob');
答案 3 :(得分:0)
select T.supervisor, F.supervisor
from emp_Super T, emp_Super F
where T.person = 'Bob'
and T.supervisor = F.person;