15,848,930 members
1.00/5 (1 vote)
See more:
SQL
`customer table (CUST_ID,CUST_NAME,CUST_ADDRESS,EMP_ID)`
SQL
`take table (CUST_ID,LOAN_NUMBER)`
SQL
`table loan (LOAN_NUMBER,AMOUNT,BRANCH_NAME)`

Find the customer name, loan number and loan amount of all customers having a loan
at the Perryridge branch.

What I have tried:

SQL
```select c.cust_name, l.loan_number,l.amount
from customer c,loan l,take t
join take t on c.cust_id=t.cust_id
join loan l on l.loan_number=t.loan_number
where branch_name=’perryridge’;```
Posted
Updated 9-Apr-23 21:20pm
v2

## Solution 1

This should give you an idea:
SQL
```SELECT
c.cust_name,
l.loan_number,
l.amount
FROM customer c
LEFT JOIN take t ON t.cust_id = c.cust_id
LEFT JOIN loan l ON l.loan_number = t.loan_number
WHERE l.branch_name = ’perryridge’ AND NOT l.loan_number IS NULL```

Ok, it is just a guess according the information we have so far.

v3
Abed Al Rahman Hussien Balhawan 2-Mar-20 11:08am
i tried this one before seeing your idea and it worked , would u accept it as a solution aswell ?

select c.cust_name, t.loan_number,l.amount,l.branch_name
from customer c
join take t on c.cust_id=t.cust_id
join loan l on l.loan_number=t.loan_number
where l.branch_name='Perryridge'
[no name] 2-Mar-20 11:12am
"would u accept it as a solution aswell ?"
The only one who can accept the solution is you ;)

In case you asking is your SQL ok: Now I would say it is important to check `AND NOT l.loan_number IS NULL`. This prevent you to check unimportant resuls in the code.

Thank you for accepting
Abed Al Rahman Hussien Balhawan 2-Mar-20 11:21am
thank you for the help and clarification wish you all the best in your career. :)
i would rate you 10 star vote if possible.
[no name] 2-Mar-20 11:26am
You are very welcome. Thank you also and while I'm trying to help I'm still learning also ;) All the best for you also.
Maciej Los 2-Mar-20 11:40am
5ed!