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 Querying Relational Databases Joining Table Data with SQL JOIN Queries

My answer is correct but still showing error

select m.MakeName as MakeName, m.ModelName as ModelName, c.VIN as VIN, c.StickerPrice as StickerPrice from (select MakeName, ModelID, ModelName from Make as ma inner join Model as mo on ma.MakeID = mo.ModelID) as m inner join Car as c on m.ModelID = c.ModelID

Which question is this for? There are 5.

1 Answer

Steven Parker
Steven Parker
231,269 Points

You're really close, but you're joining on dissimilar terms: "ma.MakeID = mo.ModelID". Those should both be the same (MakeId).

Also, while this will work when fixed, you could simplify the query a good deal and still pass:

  • you don't need a sub-query since JOINs can be chained
  • you don't need any column aliases for the SELECT clause
  • you don't need to qualify the columns with table aliases