我正在尝试寻找一种好的、高效的方法来运行像这样的查询:
SELECT *
FROM tableA a
WHERE a.manager IN ( SELECT id
FROM tableB b
CONNECT BY PRIOR b.id = b.manager_id
START WITH b.id = 'managerBob')
OR a.teamLead IN ( SELECT ID
FROM tableB b
CONNECT BY PRIOR b.ID = b.manager_id
START WITH b.ID = 'managerBob')
OR a.creator IN ( SELECT id
FROM tableB b
CONNECT BY PRIOR b.id = b.manager_id
START WITH b.id = 'managerBob')
您可以看到,我正在尝试使用多个WHERE子句,但每个子句都在等式的右侧使用相同的数据集。如果我使用多个子句,它似乎运行非常缓慢,我很确定这是因为Oracle正在运行每个子查询。有没有办法使这样的东西工作?
SELECT *
FROM tableA a
WHERE a.manager,
a.teamLead,
a.creator in ( SELECT id
FROM tableB b
CONNECT BY PRIOR b.id = b.manager_id
START WITH b.id = 'managerBob')
顺便说一下,如果我可以通过谷歌搜索得到这个信息,我很抱歉,我不确定该如何称呼这个东西。