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

Tadjiev Codes
Tadjiev Codes
9,626 Points

In a car database there is a Model table with columns, ModelID, MakeID and ModelName and a Car table with columns, CarID

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.

Kind of stuck with this as don't understand which foreign key should be connected through inner join?

3 Answers

Tadjiev Codes
Tadjiev Codes
9,626 Points
SELECT modelname, vin, stickerprice 
FROM model AS m INNER JOIN car AS c 
ON m.modelid = c.modelid;

Alright this seems to work

Mark Sebeck
Mark Sebeck
Treehouse Moderator 37,905 Points

Awesome! Glad you were able to solve with just a little hint.