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 trialDeborah Watson
2,614 PointsSubquries
Using IN: 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.
Use a subquery along with IN to list all the Model Names with a Sticker Price greater than $3000
I don't get it.......
SELECT ModelName, ModelID, StickerPrice FROM Model AS md WHERE ModelID IN ( SELECT StickerPrice FROM Car AS cr WHERE StickerPrice > 30000);
2 Answers
Steven Parker
231,268 PointsYou're close, but I see two issues. First, the instructions only ask for Model Names in the final output.
Second, whatever you're tying to match with the membership operator (IN) must be present in the subquery:
WHERE ModelID IN ( SELECT StickerPrice --...
-- ^^^^^^^ ^^^^^^^^^^^^
-- these items need to match
Deborah Watson
2,614 PointsGot it!
SELECT ModelName FROM Model AS md WHERE ModelID IN ( SELECT ModelID FROM Car AS cr WHERE StickerPrice > 30000);
Deborah Watson
2,614 PointsDeborah Watson
2,614 PointsI thought your answer was great! Helped my a lot.