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 trial

Databases

What's the problem with my command, The subquery didn't return all CustomerIDs for people who identify as female (F).

The database does return all of them and this is my command, what's wrong? SELECT * FROM Sale AS s INNER JOIN (SELECT * FROM Customer AS c WHERE c.Gender == 'F') AS customer ON s.CustomerID = customer.CustomerID

2 Answers

Steven Parker
Steven Parker
231,248 Points

It looks like you have a typo.

Either that, or you're just used to programming in other language(s). In SQL, the equality comparison is a single equal sign ("='). Some other hints:

  • you don't need a table alias inside the subquery (where there is only one table)
  • you generally don't need to mix JOINs and subqueries, the subquery can be part of a WHERE clause

And in future, to enable the most accurate and complete answers, always show your code and also provide a link to the course page you are working with.

Even if I use a single equal sign it still is the same :/ the course page im working with is this

my new code:

SELECT * FROM Sale AS s INNER JOIN (SELECT * FROM Customer WHERE Customer.Gender = 'F') AS customer ON s.CustomerID = customer.CustomerID

Steven Parker
Steven Parker
231,248 Points

You overlooked the second item of my "other hints"!

Just like task 1 and task 2 that you have already passed, this task does not use a JOIN. Rework the query to use only the subquery as directed in the instructions.

but when I don't use a join it tells me I'm missing the inner join keyword

Steven Parker
Steven Parker
231,248 Points

Oh, you didn't mention which task you were on, it looked like you were on task 3.

But I already answered your newer question.

Elizabeth Hicks
Elizabeth Hicks
44,877 Points

I had a lot of trouble with this challenge also. There is no reason the subquery should require only CustomerID to be returned. And the hint about why it still fails wasn't obvious to me either. I'd suggest a rework of this challenge for the future. There are almost always multiple ways to solve a problem and forcing the answer to be done precisely one way that isn't spelled out in the challenge itself seems like unnecessary roadblocks for users trying to learn.