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 Querying Relational Databases Subqueries Subqueries

Tommy Gebru
Tommy Gebru
30,164 Points

Challenge Task 4 of 4 Bummer: SQL Error: near "SELECT": syntax error

This is the last challenge task 4 of 4, I couldnt get to an answer or even get a different error message for a while, so I thought to share it here with the community

SELECT *
FROM Sale
INNER JOIN Customer
(SELECT CustomerID
FROM Customer
WHERE Gender = 'F'
) AS "isFemale"
ON Sale.CustomerID = isFemale.CustomerID;

2 Answers

Gabriel Plackey
Gabriel Plackey
11,064 Points

Okay, making progress. With your inner join, you don’t need the table name “customer”. You’re joining a sub query, not a table. So it would be inner join (subquery) as alias on whatever. I think that should do it. But let me know.

Tommy Gebru
Tommy Gebru
30,164 Points

Oh wow that did it - i removed the table name

SELECT *
FROM Sale
INNER JOIN
(SELECT CustomerID
FROM Customer
WHERE Gender = 'F'
) AS "isFemale"
ON Sale.CustomerID = isFemale.CustomerID;
Gabriel Plackey
Gabriel Plackey
11,064 Points

What is you current answer to the challenge? Going blindly on this but based on your error and what I believe the correct answer is, you may need to alias your query join, as something like 'c' then do c.customerID

Tommy Gebru
Tommy Gebru
30,164 Points

I went ahead and shared my code above in the description. I created an ALIAS and provided it as the JOIN criteria at the end of the code

BTW: I got a new error message so treat this as a new question too :eyes: