Oracle 右外连接
我有一个 oracle sql,在帐户表和付款表之间进行外连接。我想知道仅当付款表中存在匹配记录时如何执行条件 p. payment_status_code = 'R' 。对于其余的情况,不应执行该条件。
FROM
accounts a, payments p
WHERE (a.account_balance <= a.low_balance_level OR a.account_balance <= 0)
AND a.account_id = p.account_id(+)
AND p.payment_status_code = 'R'
问候, -阿南德
I have a oracle sql where I do an outer join between the accounts table and payments table. I want to know how to execute the condition p.payment_status_code = 'R' only when there is a matching record in the payments table. For the rest, the condition should not be executed.
FROM
accounts a, payments p
WHERE (a.account_balance <= a.low_balance_level OR a.account_balance <= 0)
AND a.account_id = p.account_id(+)
AND p.payment_status_code = 'R'
Regards,
-Anand
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果我理解正确的话,您只想用
payment_status_code = 'R'
显示结果,对吗?在这种情况下,为什么需要使用外连接?您可以只使用传统的连接。你想做什么?如果您想显示帐户信息,即使对于那些没有付款的人,您也可以使用左外连接而不是右外连接
If I understand you correctly, you only want to show the results with
payment_status_code = 'R'
, right? In that case why would you need to use outer join? You could just use the traditional join. What are you trying to do?If you want to show the account info, even for those without payment then you would use a left outer join instead of right outer join