作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想知道:在同一分行同时拥有账户和贷款的客户是谁?
我尝试了如下两段代码:
select distinct depositor.customer_name, account.branch_name
from (borrower inner join loan on borrower.loan_number=loan.loan_number)
inner join
( depositor inner join account on depositor.account_number=account.account_number )
on (account.branch_name=loan.branch_name and borrower.customer_name=depostior.customer_name);
还有这个:
select account.branch_name, depositor.customer branch_name
from account, depostior
where depositor.customer_name, account.branch_name
in ( borrower inner join loan on borrower.loan_number=loan.loan_number );
在最新的一个中,我以某种方式尝试了嵌套查询,但没有成功。
那么我该如何解决这个问题呢?谢谢
最佳答案
select distinct d.customer_name, a.branch_name
from depositor d, account a, borrower b, loan l
where
d.account_number = a.account_number
and d.customer_name = b.customer_name
and b.loan_number = l.loan_number
and l.branch_name = a.branch_name
用 INNER JOIN 语法重写
SELECT DISTINCT d.customer_name, a.branch_name
FROM depositor d
INNER JOIN account a ON d.account_number = a.account_number
INNER JOIN borrower b ON d.customer_name = b.customer_name
INNER JOIN loan l ON b.loan_number = l.loan_number
AND l.branch_name = a.branch_name
关于mysql - 谁是在同一分行同时拥有账户和贷款的客户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33714749/
我正在尝试编写一个 SQL 查询来根据以下公式计算 future 贷款余额: FV( future 余额)= CV(当前余额)- P(固定还款)+ I (利息资本化) 其中 **I = (CV * A
我是一名优秀的程序员,十分优秀!