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!

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 Subqueries Subqueries

Subquery using IN

These subquery lessons have me super confused. I've copied and pasted my code below, it keeps saying I can't use more than 1 column in my subquery....

SELECT ModelName FROM Model WHERE StickerPrice IN (SELECT StickerPrice FROM Car WHERE StickerPrice < '$30,000');

1 Answer

Steven Parker
Steven Parker
227,141 Points

Here's a few hints:

  • the subquery can filter on StickerPrice, but it must SELECT a column that both tables have in common
  • the outer query will then filter using the common column
  • the StickerPrice will be a number, not a string