Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools

SQL 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: 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
PLUS
Guillaume Maka
Courses Plus Student 10,224 Points

Try

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;

Big big thankyou! This was annoying me to death.

Oh 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
Guillaume Maka
Courses Plus Student 10,224 Points
SELECT title, name 
FROM movies 
LEFT OUTER JOIN genres 
ON movies.genre_id = genres.id;
Guillaume Maka
PLUS
Guillaume Maka
Courses Plus Student 10,224 Points
SELECT title, name 
FROM movies 
LEFT OUTER JOIN genres 
ON movies.genre_id = genres.id;

You did it again, thanks for helping me finish the stage!