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

Nancy Melucci
PLUS
Nancy Melucci
Courses Plus Student 36,143 Points

Joining tables

Here it is again....I am still not getting it (apparently) - this is the first challenge question

MY QUERY:
SELECT*FROM movies INNER JOIN genres ON movies.title = genres.name

ERROR MESSAGE: Bummer! You're not retrieving the movie 'title' first and the genre 'name' second. Use an INNER JOIN.

3 Answers

First you need to define what you want to select from each table; you do not want to use the asterisks (*) to select all because you are explicitly selecting columns. The question asks you to select "the movie 'title' first and the genre 'name' second". This starts your query with "SELECT movies.title, genres.name".

Your FROM and INNER JOIN is correct - "FROM movies INNER JOIN genres".

Now, your joining on the 'genre_id' from the movies table and the 'id' from the genres table. So your join ON statement should place "movies.genre_id = genres.id". Be sure to get in the habit of ending your statement with a semi colon (;).


Here is a HINT. When you want to see what the table looks like, you can run a query "SELECT * FROM movies;" and another "SELECT * FROM genres;". Of course you will get the answer wrong, but you will see the result in the result window. With looking at those results, it will assist you in visualizing what you need to do to join the information together.

James Corr
James Corr
2,678 Points

Hey Duane Moody thanks for posting the above!

I'm working through this example right now and my query looks like this:

SELECT movies.title, genre.name FROM movies INNER JOIN genres ON movies.genre_id = genres.id; .......but I'm getting an error, so I came to the forums to look for reasoning and found this post.

So I tried adding the " s you used above thinking that might fix it so it looks like this now: SELECT movies.title, genre.name FROM movies INNER JOIN genres ON "movies.genre_id" = "genres.id"; .....but still getting an error.

What am I doing wrong?

Sorry I did not see your reply until just now. You do not want to use the quotation marks in your query. I only used quotation marks to make the query language standout from the sentence..

James Corr
James Corr
2,678 Points

Hey Duane Moody thanks for posting the above!

I'm working through this example right now and my query looks like this:

SELECT movies.title, genre.name FROM movies INNER JOIN genres ON movies.genre_id = genres.id; .......but I'm getting an error, so I came to the forums to look for reasoning and found this post.

So I tried adding the " s you used above thinking that might fix it so it looks like this now: SELECT movies.title, genre.name FROM movies INNER JOIN genres ON "movies.genre_id" = "genres.id"; .....but still getting an error.

What am I doing wrong?