如何写查询客户A借了多少

时间:2015-09-25 20:10:44

标签: sql oracle oracle10g

我有以下表格帐户,分行,客户,贷款,借款人,存款人..

如何写出查询多少' customerA'借

我尝试写

select borrower.customer_name, loan.amount from borrower, loan
where borrower.loan_number=loan.loan_number and customer_name = 'customerA';

显示未选择任何行 我是新来的查询..pls帮助

1 个答案:

答案 0 :(得分:0)

顺便说一下,隐式连接(在from子句中有两个表)是一种不推荐使用的语法,建议切换到现代的显式语法:

如果您使用别名也有帮助。

select B.customer_name, L.amount 
from borrower as B
inner join loan as L
   ON B.loan_number = L.loan_number
where  
   B.customer_name = 'customerA';

正如sstan建议查询看起来没问题。尝试删除where部分,看看是否有关于连接结果的任何数据。