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.
David Curran7,679 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 Parker221,451 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,029 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 Gates14,935 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".