我有数据表说
角色定位
RL1 CR1 LG1
RL2 CR2 LG2
RL3 CR3 LG3
RL4 CR4 LG4
RL5 CR5 LG1
RL6 CR6 LG1
契约角色
CR1 Policy1
CR2 Policy1
CR3 Policy1
CR4 Policy1
CR5 Policy2
CR6 Policy2
我只想取
RL2
RL3
RL4
所以我在下面写的查询工作正常,但我怀疑它会表现良好..任何帮助表示赞赏。谢谢
SELECT
RL.ROLE_LOCATION_ID
FROM
ROLELOCATION RL, contractrole CR
WHERE
CR.CONTRACT_ROLE_ID = RL.CONTRACT_ROLE_ID
AND CR.CONTR_COMPONENT_ID = policy1
AND RL.LOCATION_GROUP_ID NOT IN (SELECT RL2.LOCATION_GROUP_ID
FROM ROLELOCATION RL2,CONTRACTROLE CR2
WHERE RL2.CONTRACT_ROLE_ID = CR2.CONTRACT_ROLE_ID
AND CR2.CONTR_COMPONENT_ID <> policy1)