如何在Oracle中找到没有重复的确切匹配记录
在表中我使用以下查询来查找基于以下值的写入访问的用户,我该如何找到确切的匹配。 注意 - 每个客户可以有多个用户 示例 - 用户**写**用户 - {ui.access,api.access}和
用户** b读**用户 - {ui.access,api.access,ui.readonly,api.readonly}
> 查询应仅返回用户
在下方尝试 -
select DISTINCT ul.ID from CUSTOMER cus join USER_LOCAL ul on cus.ID = ul.CUSTOMER_ID
join USER_SECURITY_ROLE ur on ul.ID = ur.USER_ID
join SECURITY_ROLE_PERMISSION sr on ur.SECURITY_ROLE_ID = sr.SECURITY_ROLE_ID
join SECURITY_PERMISSION sp on sr.SECURITY_PERMISSION_ID = sp.ID
where sp.PERMISSION_NAME in ('UI.ACCESS','API.ACCESS')
and ul.ID not in
(select DISTINCT ul.ID from CUSTOMER cus join USER_LOCAL ul on cus.ID = ul.CUSTOMER_ID
join USER_SECURITY_ROLE ur on ul.ID = ur.USER_ID
join SECURITY_ROLE_PERMISSION sr on ur.SECURITY_ROLE_ID = sr.SECURITY_ROLE_ID
join SECURITY_PERMISSION sp on sr.SECURITY_PERMISSION_ID = sp.ID
where sp.PERMISSION_NAME in ('UI.READONLY','API.READONLY'));
我们有什么优化的方法可以做到吗?
How can I find the exact match in case of duplicate values in tables I am using the below query to find users which are having write access based on the below values.
Note - Each customer can have multiple usersExample - user **A write** user - {UI.ACCESS, API.ACCESS} and
user **B read** user - {UI.ACCESS, API.ACCESS, UI.READONLY, API.READONLY}
query should return only A user
tried below way -
select DISTINCT ul.ID from CUSTOMER cus join USER_LOCAL ul on cus.ID = ul.CUSTOMER_ID
join USER_SECURITY_ROLE ur on ul.ID = ur.USER_ID
join SECURITY_ROLE_PERMISSION sr on ur.SECURITY_ROLE_ID = sr.SECURITY_ROLE_ID
join SECURITY_PERMISSION sp on sr.SECURITY_PERMISSION_ID = sp.ID
where sp.PERMISSION_NAME in ('UI.ACCESS','API.ACCESS')
and ul.ID not in
(select DISTINCT ul.ID from CUSTOMER cus join USER_LOCAL ul on cus.ID = ul.CUSTOMER_ID
join USER_SECURITY_ROLE ur on ul.ID = ur.USER_ID
join SECURITY_ROLE_PERMISSION sr on ur.SECURITY_ROLE_ID = sr.SECURITY_ROLE_ID
join SECURITY_PERMISSION sp on sr.SECURITY_PERMISSION_ID = sp.ID
where sp.PERMISSION_NAME in ('UI.READONLY','API.READONLY'));
is there any optimized way we can do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题尚不清楚100%,但似乎您在数据模型 /应用程序设计中遇到了问题。也就是说,“用户a”具有写入访问的事实不应由
ui.readonly
/api.readonly 安全>安全>安全>安全>安全>安全>允许。相反,应该有一个
ui.write
/api.write
您的查询正在寻找的许可。但是,假设您现在无法解决该问题,则可以尝试这样的查询:
这将为您提供具有
ui.access
和api.access
的用户ID。 ,但不是ui.readonly
和api.readonly
的任何一个或两个。Your question isn't 100% clear, but it seems like maybe you have a problem in your data model / application design. Namely, the fact that "user A" has write access should not be indicated by the absence of a
UI.READONLY
/API.READONLY
security permission. Rather, there should be aUI.WRITE
/API.WRITE
permission that your query is looking for.But assuming you can't fix that issue right now, you might try a query like this:
This will give you the user IDs that have
UI.ACCESS
andAPI.ACCESS
, but not either or both ofUI.READONLY
andAPI.READONLY
.