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

Pedro Baumann
Pedro Baumann
12,815 Points

Joining Tables and Aliasing error problem (code challenge) [SOLVED]

Hi, I'm having a problem with the 1st task of the last code challenge for the Database Deep Dive.

The question is the nextone:

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.

My answer is this:

SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genres_id = genres.name;

Workbench says my syntax is correct and proceses the request, but in the challenge this is the error that apears and it's leaved me clueless:

0c374a88-ddfa-4052-b1a8-a9efc51cdb6e.rb:39:in eval': undefined methodto_a' for "SQL Error: Unknown column 'movies.genres_id' in 'on clause'":String (NoMethodError) from 0c374a88-ddfa-4052-b1a8-a9efc51cdb6e.rb:39:in eval' from 0c374a88-ddfa-4052-b1a8-a9efc51cdb6e.rb:39:in<main>'

Any clues?

Thanks!

EDIT: I was adding an extra "s" to genre_id....nvm

3 Answers

Jefry Cruz
Jefry Cruz
15,700 Points

Hey Andre this is he exact statement I'm inputting for this challenge and it's not going through.

SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genre_id = genres.name;

What am I doing wrong as I'm pretty sure I'm doing it correctly.

Thanks in advance.

Jefry Cruz
Jefry Cruz
15,700 Points

aha I had to replace genres.name with genres.id

This is the exact same code that I have been putting in but I am getting the following error: You're not retrieving the movie 'title' first and the genre 'name' second. Use an INNER JOIN.

SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genre_id = genres.name;

Any help would be amazing!

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

Since there were no examples in this segment using the "FIRST" keyword I am puzzled by the error I keep getting that I am not selecting movies.title first. I am typing that first in the query. Really lost for the first time in this course. Any scaffolding you can provide will help. I've come this far and I'd like to finish.