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 Querying Relational Databases Joining Table Data with SQL JOIN Queries

Tatia Burdett
Tatia Burdett
1,470 Points

LEFT OUTER JOIN, selecting from two tables, not resulting as expected.

I'm getting the error: "Your query didn't select the ModelName and VIN correctly!"

The question is to join two tables so that all the car models display, even if they are not included in the Car table. The two tables are Model and Car -- Car has the foreign key, referencing the Model table.

Here is my query:

Select md.ModelName, car.VIN FROM Car AS car LEFT OUTER JOIN Model AS md ON car.ModelID = md.ModelID;

The key name is correct...

1 Answer

ivana kantnerova
ivana kantnerova
15,932 Points

Select md.ModelName, car.VIN FROM Car AS car LEFT OUTER JOIN Model AS md ON car.ModelID = md.ModelID;

left means the actual physical position in the clause .. so you have selected all the cars, not all the models

so i think it should be like this: Select md.ModelName, car.VIN FROM Model AS md LEFT OUTER JOIN Car AS car ON car.ModelID = md.ModelID;