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 trialAlejandro Cavazos
4,250 PointsSQL Code Challenge - Please help!
Hello Treehouse! I am having the following problem with a SQL Code Challenge. I've tried lots and lots of queries and I've had no luck.
Here is the code challenge:
Here is the query I am using:
SELECT title, name
FROM movies
INNER JOIN name ON movies.genre = genres.id
Thanks in advance. This challenge is driving me crazy and won't let me complete the stage.
2 Answers
Guillaume Maka
Courses Plus Student 10,224 PointsTry
SELECT title, name
FROM movies
INNER JOIN genres
ON movies.genre_id = genres.id;
You have two choices for INNER JOIN
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;
or:
SELECT column_name(s)
FROM table1
JOIN table2
ON table1.column_name=table2.column_name;
Guillaume Maka
Courses Plus Student 10,224 PointsSELECT title, name
FROM movies
LEFT OUTER JOIN genres
ON movies.genre_id = genres.id;
Alejandro Cavazos
4,250 PointsYou did it again, thanks for helping me finish the stage!
Alejandro Cavazos
4,250 PointsAlejandro Cavazos
4,250 PointsBig big thankyou! This was annoying me to death.
Guillaume Maka
Courses Plus Student 10,224 PointsGuillaume Maka
Courses Plus Student 10,224 PointsYou're welcome !
Alejandro Cavazos
4,250 PointsAlejandro Cavazos
4,250 PointsOh well, I realized that the second question is even harder. This time, asking for an outer join. How would the outer join version go?
Like before, bring back the movie 'title' and genre 'name' but use the correct OUTER JOIN to bring back all movies, regardless of whether the 'genre_id' is set or not.
Guillaume Maka :)
Guillaume Maka
Courses Plus Student 10,224 PointsGuillaume Maka
Courses Plus Student 10,224 Points