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

Development Tools

Charles Kaelin
Charles Kaelin
4,003 Points

Code Challenge Question: Joining Relational Data Between Tables in SQL

I'm having difficulty finding a solution to this specific question:

"Code Challenge Question #2: Like before bring back the movie 'title' and genre 'name' but use the correct OUTER JOIN to bring back all movies regardless if the 'genre_id' is set or not."

I've attempted to answer this question in about 20 different ways, but have been unsuccessful in finding the correct solution.

Here is my best guess at solving the question: SELECT movies.title, genres.name FROM movies LEFT OUTER JOIN genres ON movies.genre_id = genres.id WHERE movies.genre_id IS NOT NULL;

Again, I've tried modifying this offered solution about 20 different ways.

Any help would be highly appreciated.

Thanks, Charles

I could use some clarification on both challenge questions topics.

Specifically, the LEFT vs RIGHT OUTER JOIN, INNER JOIN, ON movies.genre_id = genres.id, and WHERE movies.genre_id IS NOT NULL parts.

The ideas are not clear to me yet. I will watch this video again.

Any clarification is appreciated.

2 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Hi Charles Kaelin,

You're almost there! The question is asking you to return it if the id is set or not.

The LEFT OUTER JOIN will return all movies anyway. The WHERE movies.genre_id IS NOT NULL; isn't will only bring back movies that are set only. This is the equivalent of doing an INNER JOIN :)

Hope that helps!
Regards
Andrew

Charles Kaelin
Charles Kaelin
4,003 Points

SELECT movies.title, genres.name FROM movies LEFT OUTER JOIN genres ON movies.genre_id = genres.id WHERE movies.genre_id IS NOT NULL;