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 trialShawn Jass
7,151 PointsTrying to check Challenge Task 1 of 5 --In a car database...
I'm trying to figure out why this code doesn't work as it keeps giving you're missing JOIN..
Challenge Task 1 of 5
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. Type in your command below.
SELECT mk.MakeID, v.VIN, sp.StickerPrice FROM Model AS md INNER JOIN make AS mk ON mk.MakeID = md.MakeID WHERE MakeName, VIN, Sticker Price;
SQL Error: near ",": syntax error
6 Answers
Seth Kroger
56,413 PointsThe WHERE clause should be a conditional, not a list of columns. This is where the syntax error is coming from. It looks like you put the list of columns to display there. The list of columns to display should always be in the SELECT clause so you should start out with:
SELECT ModelName, VIN, StickerPrice FROM Car
The Car table doesn't have ModelName but a reference to the Model table we need to continue with a join:
INNER JOIN Model
And use the ModelID for the reference:
ON Model.ModelID = Car.ModelID
Since you're listing all cars, you don't need a WHERE clause.
Alain De La Cuadra
21,890 PointsPlease help me iam stuck 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. Show all Model names from the Model table along with VIN from the Car table. Make sure models that arenβt in the Car table still show in the results!
Bruce McMinn
10,030 PointsThis is what worked for me:
SELECT Model.ModelName, Car.VIN, Car.StickerPrice FROM Model
INNER JOIN Car ON Model.ModelID = Car.ModelID;
I'm guessing that other than syntax, the difficulty is in the ON portion...
Tinashe Mutematsaka
9,087 PointsSELECT Make.MakeName AS "Make Name", Model.ModelName AS "Model Name", Car.VIN AS "VIN", Car.StickerPrice AS "Sticker Price" FROM Car INNER JOIN Model ON Model.ModelID = Car.ModelID INNER JOIN Make ON Make.MakeID = Model.MakeID;
Sasha Matviienko
2,696 PointsSame question, can you please explain where is a mistake in this code:
SELECT make.MakeName, model.ModelName, car.VIN, car.StickerPrice FROM make INNER JOIN car ON make.MakeID = car.ModelID INNER JOIN model ON car.ModelID = model.ModelID;
Kevin Gates
15,053 PointsSometimes it helps to space out your syntax:
SELECT m.ModelName, c.VIN, c.StickerPrice
FROM Model AS m
INNER JOIN Car AS c
ON m.ModelID = c.ModelID;
Maryam Naz
3,636 PointsThis one works too, if you wanna skip aliasing...
SELECT ModelName, VIN, StickerPrice FROM Model INNER JOIN Car ON MODEL.ModelID=CAR.ModelID;
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsCan you provide a link to the code challenge?
EDIT: can you also show us your code?
~Thanks, Alex