August 31, 2022 at 5:01 pm
I'm a real beginner of SQL and have not managed to solve this.
I'm trying to join all the information below. For this I want to use the customer_id whos in table 1 and table 2. The first step will be to join the last_name (table 2) into the new table. In the next step I also want to join the first name into that table, so the columns will be: customer_id, Limit, last_name, first_name. Anyone who can explain how to do it?
August 31, 2022 at 5:17 pm
While I appreciate this may be a homework set of tables and data, there is a very serious design flaw in the above and that is in the customer credit table.
You should have a customer ID column here and you shouldn’t be reliant on joining based on the name columns.
e.g what is you had Will Smith and Daniel Smith as customers, when you join back to customer ledger which Smith is which here?
Anyway that is by the by but this design isn’t showcasing proper database design, so take what you are learning in this database with a big pinch of salt.
Back to the question at hand
so you will want
Select
....
From CustomerLimit
Inner join customerledger
On customerlimit.customer_id = customerledger.customer_id
Inner join customercredit
On customerledger.last_name = customer credit.last_name
Select
Customerlimit.customer_id, customerlimit.limit,
Customercredit.first_name,
Customercredit.last_name
From CustomerLimit
Inner join customerledger
On customerlimit.customer_id = customerledger.customer_id
Inner join customercredit
On customerledger.last_name = customer credit.last_name
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply