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

Inner joins problem task 2

select MakeID, MakeName from Make
inner join Model on Make.MakeID = Model.MakeID
inner join Car on Model.ModelID = Car.ModelID;

What's wrong with the above? Help appreciated!

1 Answer

Kendell Dancy
Kendell Dancy
15,017 Points

You almost had it. Looks like you just forgot to select the fields they were asking for. (MakeName, ModelName, VIN, StickerPrice)

In a car database there is...

a Make table with columns, MakeID and MakeName

a Model table with columns, ModelID, MakeID and ModelName

a Car table with columns, CarID, ModelID, VIN, ModelYear and StickerPrice

For all cars in the database,

Show MakeName, ModelName, VIN and StickerPrice from the Model and Car tables in one result set.

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