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 trialTaylor Rogers
806 PointsI am having trouble on the second task. I'm not sure I'm understanding this correctly.
I am having trouble selecting all of the movies, regardless of whether the 'genre_id' exists or not. Below is the join that I wrote and it doesn't seem to be working. I've tried changing it up a bit with no luck. Any help would be appreciated!
SELECT movies.title, genres.name FROM movie LEFT OUTER JOIN genres ON movies.genre_id=genres.id WHERE movies.genre_id IS NOT NULL;
2 Answers
Lukas Smith
4,026 PointsU doing SELECT movies.title, genres.name FROM movie ??? so check what is your table name: movie ? or movies ? and better is use alias like: SELECT mov.title, gen.name FROM movie mov LEFT OUTER JOIN genres gen ON mov.genre_id=gen.id WHERE mov.genre_id IS NOT NULL;
James Anwyl
Full Stack JavaScript Techdegree Graduate 49,960 PointsYou don't need the WHERE clause as you are trying to include all movies (even the ones without a genre_ID). By saying WHERE genre_id IS NOT NULL you are excluding entries that don't have a genre_ID (i.e the genre_id = NULL). We want to include them, so just do:
SELECT movies.title, genres.name FROM movies LEFT OUTER JOIN genres ON movies.genre_id = genres.id;
Hope this makes sense :)
Taylor Rogers
806 PointsOkay it worked thank you!!
Taylor Rogers
806 PointsTaylor Rogers
806 PointsThanks!