Databases Querying Relational Databases Joining Table Data with SQL JOIN Queries

Abdelhadi Boukdir
Abdelhadi Boukdir
386 Points

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

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,537 Points

Which question is this for? There are 5.

1 Answer

Steven Parker
Steven Parker
182,438 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