Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases Querying Relational Databases Joining Table Data with SQL JOIN Queries

Teacher Russell
Teacher Russell
16,873 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,873 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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,704 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.