Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTyler McDougal
2,549 PointsI Need help trying to solve this:
In a car database there is a Model table with columns, ModelID, MakeID and ModelName and a Car table with columns, CarID, ModelID, VIN, ModelYear and StickerPrice. Show all Model names from the Model table along with VIN from the Car table. Make sure models that arenβt in the Car table still show in the results!
Tyler McDougal
2,549 PointsSELECT ModelName, VIN FROM Model LEFT OUTER JOIN Car ON Model.ModelName = Car.CarID INNER JOIN Car ON Car.ModelID = Model.ModelID;
Tyler McDougal
2,549 Points2 Answers
Umesh Ravji
42,386 PointsHi Tyler, you're almost there.
FROM Model
LEFT OUTER JOIN Car ON Model.ModelName = Car.CarID
The two columns ModelName
and CarID
are not related, so it doesn't make much sense to perform a join using the two.
INNER JOIN Car ON Car.ModelID = Model.ModelID;
This is exactly the part you need for your LEFT OUTER JOIN
, so once you replace the first unnecessary join with this one (and make sure it is an LEFT OUTER JOIN
, you have your answer :)
SELECT ModelName, VIN
FROM Model
LEFT OUTER JOIN Car ON Car.ModelID = Model.ModelID;
Tyler McDougal
2,549 PointsWOW!! I See where I messed up. Thanks Alot!
james south
Front End Web Development Techdegree Graduate 33,271 Pointsit's asking you to use a type of join that includes records even if they don't have a match, so focus on that. the two tables have a common column that is used to join them.
Umesh Ravji
42,386 PointsUmesh Ravji
42,386 PointsWhat have you written so far? Share it with us :)