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

Chris Reich
Chris Reich
15,163 Points

Thee Inner Join Syntax - what am I missing?

SELECT MakeName, ModelName, VIN, StickerPrice FROM Make INNER JOIN Model ON MakeID WHERE Make.MakeID = Model.MakeID INNER JOIN Car ON ModelID WHERE Car.ModelID = Model.ModelID;

SQL Error: near "INNER": syntax error

What's wrong?

2 Answers

Steven Parker
Steven Parker
231,140 Points

Your JOIN syntax is a bit off.

Where you have:

... INNER JOIN Model ON MakeID WHERE Make.MakeID = Model.MakeID ...

The ON expression is not complete, and you would not put a WHERE clause before another JOIN. So you probably meant something like this:

... INNER JOIN Model ON Make.MakeID = Model.MakeID ...

The same changes would be applicable to the other JOIN.

Next time be sure to include a link to the course page to enable the most accurate analysis.

Chris Reich
Chris Reich
15,163 Points

Thanks. I figured it out. Just need to remove the WHERE when using multiple INNER JOINs.

SELECT MakeName, ModelName, VIN, StickerPrice FROM Make INNER JOIN Model ON Make.MakeID = Model.MakeID INNER JOIN Car ON Car.ModelID = Model.ModelID;