已有递归查询
with my1
as
(
select * from rel_Duty where duty_EmpCode='ab807d4d-0fa7-43f2-8264-63cf1b11edc5'
union all
select r1.* from my1,rel_Duty r1 where my1.parent_ID = r1.ID
)select * from my1;
可以根据某个人查询出其所有上级部门来 ,但我想实现的是对比查询出来的部门中是否含有某个部门。
这种业务逻辑不建议放到sql中写吧,
但问题是必须要在用sql语句运行
try
select * from
(with my1
as
(
select * from rel_Duty where duty_EmpCode='ab807d4d-0fa7-43f2-8264-63cf1b11edc5'
union all
select r1.* from my1,rel_Duty r1 where my1.parent_ID = r1.ID
)select * from my1) as tt
where name in ('name')
;