为什么在 Oracle 中下面的查询不起作用?
select * from ENTITY_OWNERSHIP EO
where
(select count (*)
from (
select USER_ID
from ENTITY_OWNERSHIP
where ENTITY_OWNERSHIP.ENTITY_ID = EO.ENTITY_ID
)
) > 0
当我使用EO.ENTITY_ID时,它会产生“ORA-00904: "EO"."ENTITY_ID": invalid identifier”的错误。然而,当我将EO.ENTITY_ID替换为确切的值,例如10181,则可以正常工作。
更新: 完整查询如下:
select * from ENTITY_OWNERSHIP EO
where
(select count (*)
from (
select USER_ID
from ENTITY_OWNERSHIP
where ENTITY_OWNERSHIP.ENTITY_ID = EO.ENTITY_ID
intersect
select distinct group_id
from USERS.GROUPS
start with GROUP_ID in (select GROUP_ID from USERS.LK_GROUPS where USER_ID=10001)
connect by prior PARENTGROUP_ID=GROUP_ID
)
) > 0