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 trialBill Ertle
9,286 Pointsusing an inner join in database foundations
the question is: use an INNER JOIN to join the 'movies' and ''genres' tables together only selecting the movie 'title' first and the genre 'name' second.
here's my answer: SELECT * FROM movies INNER JOIN genres ON movies.title = genres.name;
treehouse says my answer is wrong, can anyone help? thanks!
5 Answers
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsI have located the bug: genre.name should be genres.name.
SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genre_id = genres.id;
For the sake of visualization, here is the link to the challenge :
Lindsay Sauer
12,029 PointsHi Bill,
It sounds like it's asking you to select two fields, title and name. Your current select uses the wildcard asterisk so it is selecting everything.
The Inner Join should also be done where there is a match between the columns in both tables, as a means to link the two. So without seeing the structure of the tables, I'd guess the select statement should be something like:
SELECT movies.title, genre.name FROM movies INNER JOIN genres ON movies.genre_id = genres.genre_id;
Bill Ertle
9,286 Pointsthank you, lindsay!
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsHi Biil,
Here is a brief explanation to augment Lindsay's answer above:
You need to SELECT specific columns (movies.title and genres.name....title and name are both columns in the movie table) FROM a table (movies) and INNER JOIN them to another table (genres) ON specific id matching a value (movies.genre_id and genres.id).
Bill Ertle
9,286 Pointsthank you lindsay and juliette for your responses...however, when i try lindsay's answer, i get the following error message:
You're not retrieving the movie 'title' first and the genre 'name' second. Use an INNER JOIN.
Lindsay Sauer
12,029 PointsHi Bill,
Can you link to the course or challenge?
Lindsay Sauer
12,029 PointsLindsay Sauer
12,029 PointsThank you, this is important; without knowing the table names, it would be difficult to arrive at a solution.
Bill Ertle
9,286 PointsBill Ertle
9,286 Pointsthat worked...thank you, juliette!!!