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 Database Foundations Joining Relational Data Between Tables in SQL Joining Tables and Aliasing

JOIN Challenge, Task 1

The challenge is:

We have a 'movies' table with a 'title' and 'genre_id' column

and a 'genres' table has an 'id' and 'name' column.

Use an INNER JOIN to join the 'movies' and 'genres' tables together only selecting the movie 'title' first and the genre 'name' second.

I first tried: SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genre_id = genres.id;

I got a "bummer" message saying, "You're not retrieving the movie 'title' first and the genre 'name' second. Use an INNER JOIN."

I then tried: SELECT movies.title, genres.name FROM movies LEFT OUTER JOIN genres ON movies.genre_id = genres.id;

This returned:

title name Alien Sci Fi Aliens Sci Fi Moulin Rouge Musical Guys and Dolls
Mama Mia
Starman
Tron
Die Hard

And I got the same bummer message. But this is what the teacher does in this video.

Then I tried this again: SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genre_id = genres.id;

This time it passed.

Keep in mind that I'm typing everything out here and cutting and pasting back into the challenge (open in another browser tab) so what I've posted above is what I entered, meaning that if typos or word transpositions were occurring they would have been repeated and nothing would have passed.

I'm confused. What am I missing? Was this just a hiccup in the Treehouse system when checking my entry?

1 Answer

Stone Preston
Stone Preston
42,016 Points
SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genre_id = genres.id;

is definitely the correct way to do it. sometimes the challenge engine will glitch out every now and then, so thats probably what happened. If you think you have the answer correct and its not working, try refreshing the challenge and trying it again. that will usually fix it