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 trial

Databases

Having trouble with JOINs using SQL

Challenge Task 4 of 5

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!

The instructions above are asking for some kind of JOIN between the Car table and Model table… but I cannot figure out why my code doesn't work:

SELECT * FROM Model LEFT OUTER JOIN Car ON Model.ModelID=Car.VIN;

I am trying different solutions but I am not having any luck...

SELECT ModelName, VIN FROM Model LEFT OUTER JOIN Car ON Model.ModelID=Car.CarID;

Bummer: Your query didn't select the ModelName and VIN correctly!

1 Answer

SELECT ModelName, VIN FROM Model LEFT OUTER JOIN Car ON Model.ModelID=Car.ModelID;

I figured it out.. hope this helps anyone else who was stuck