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

Hans Eisenman
Hans Eisenman
1,315 Points

Having trouble with a Join challenge. Syntax Error

Having trouble with a challenge. It reads:

Challenge Task 4 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.

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!

Seems easy enough, but I'm getting this error:

Bummer: SQL Error: near "m": syntax error.

Here's my query:

SELECT m.model, c.vin FROM model m LEFT OUTER JOIN car ON c m.ModelID = c.ModelID

Image of the whole affair hosted here: https://www.screencast.com/t/PK4Ug6QpT9

I'm not sure what the syntax error is. I've tried everything I can think of.

It's probably staring me in the face...

2 Answers

Steven Parker
Steven Parker
231,269 Points

It looks like your table alias is on the wrong side of the "ON":

...LEFT OUTER JOIN car ON c m.ModelID = c.ModelID  -- you have this
...LEFT OUTER JOIN car c ON m.ModelID = c.ModelID  -- instead of this
Hans Eisenman
Hans Eisenman
1,315 Points

Thanks Steven! That fixed it.

As a sidenote, it's kind of boggling how easy it is for one to get googley-eyed staring at the smallest line of code. I should have easily seen that and it wasn't for lack of looking...

Thanks again.

Steven Parker
Steven Parker
231,269 Points

That's a hazard all programmers face, gurus and tyros alike. Sometimes nothing beats a second pair of eyes!

Glad I could help, and happy coding!