Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases Querying Relational Databases Subqueries Subqueries

Katie Martens
Katie Martens
1,587 Points

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
216,810 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