Databases Querying Relational Databases Subqueries Subqueries

George Waller
George Waller
3,703 Points

Subquery using IN

I don't understand why this isn't selecting the ModelName's?

SELECT ModelName FROM Model INNER JOIN Car ON Model.ModelID = Car.ModelID WHERE Model.ModelID IN (SELECT ModelID FROM Car WHERE StickerPrice > 30000);

1 Answer

Steven Parker
Steven Parker
195,592 Points

You don't need a JOIN here, just the subquery:

SELECT ModelName FROM Model
  WHERE ModelID IN (SELECT ModelID FROM Car WHERE StickerPrice > 30000);