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
David Curran7,682 Points
Challenge Task 2 of 5 on Databases
In a car database there is a Make table with columns, MakeID and MakeName, 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 Make Name, Model Name, VIN and Sticker Price from the Model and Car tables in one result set.
Steven Parker229,005 Points
It looks like you just have a stray word "Model":
- your second JOIN says "
INNER JOIN Model Car" but should be "
INNER JOIN Car" (no "Model")
Just remove that word and you should pass task 2.
Bruce McMinn10,030 Points
So, is the trick that you link PK in table one to a column in table two, PK in table two to a column in table three, etc?
SELECT Make.MakeName, Model.ModelName, Car.VIN, Car.StickerPrice FROM Make
INNER JOIN Model ON Make.MakeID = Model.MakeID
INNER JOIN Car ON Model.ModelID = Car.ModelID;
Kevin Gates15,052 Points
Updated if you want guidance to shorten table names:
SELECT mk.MakeName, md.ModelName, c.VIN, C.StickerPrice
FROM Make AS mk
INNER JOIN Model AS md
ON mk.MakeID = md.MakeID
INNER JOIN Car AS c
ON md.ModelID = c.ModelID;
It should be a quick one to fix for you. You need to have both the tables in the FROM section. Add the CAR table and it should work. Let me know how you go! Good luck!
Hi David, in your original sql can you delete the model table name which is after the second inner join. It should be "inner join car" and not "inner join model car".