Databases Querying Relational Databases Joining Table Data with SQL JOIN Queries

Teacher Russell
Teacher Russell
16,868 Points

A little help with the approach of solving this challenge.

I can look at answers posted and see my error, but I'm still very fuzzy here. It would have been very helpful to have a follow up explanation of these final exercises. Can someone give a little more in-depth explanation on how to begin looking at this one? Thanks in advance!:)

Teacher Russell
Teacher Russell
16,868 Points

Sorry, I thought it would be visible. What I'm generally having trouble with is which column to select when. I just goofed on the final challenge, too. I chose FROM SalesRep, and tried to LEFT OUTER JOIN the Sale table, because I thought I needed to, to get every value from that table.
In the 2nd challenge, I believe it was a matter of placing the Car on the wrong side of the comparison.

1 Answer

Brendan Whiting
MOD
Brendan Whiting
Front End Web Development Treehouse Moderator 84,578 Points

Here is my solution, and an explanation:

SELECT Model.ModelName, Car.VIN, Car.StickerPrice FROM Model INNER JOIN Car ON Model.ModelID = Car.ModelID;
  • I'm selected all the columns that were requested by the challenge - ModelName, VIN, StickerPrice - with the explicit Column I'm selected them from. This isn't absolutely necessary but it helps make it clearer to understand.
  • I just used INNER JOIN because in this case it doesn't seem to matter. Outer joins are for letting it know what to do if there are missing values.

Let me know if you have any questions.