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

Nelson Govea
PLUS
Nelson Govea
Courses Plus Student 1,951 Points

Help with INNER JOIN

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.

For all cars in the database, show Model Name, VIN and Sticker Price in one result set.

Error Message Receiving "Bummer! Your query didn't select the ModelName, VIN and StickerPrice!"

My Command: SELECT VIN, StickerPrice FROM Car INNER JOIN Model ON Car.VIN = Model.ModelName;

Nelson Govea
Nelson Govea
Courses Plus Student 1,951 Points

HI Stuart, thank you for the help which solved the problem but how is ModelID related to VIN since its two different columns?

1 Answer

Stuart Wright
Stuart Wright
41,120 Points

Your join condition needs to be on the ModelID column from each table, and you need to include ModelName in your select statement:

SELECT ModelName, VIN, StickerPrice FROM Car INNER JOIN Model ON Car.ModelID = Model.ModelID;