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.
Forgot to add genres_id column
I've been attempting to create the Database on mySQL workbench as I have been watching through the videos.
It seems somewhere I have possibly forgotten to add the genres_id as it is not currently shown in my 'genres' table.
This is the error message being returned:
"10:00:56 SELECT * FROM movies JOIN genres ON movies.genre_id = genres_id LIMIT 0, 1000 Error Code: 1054. Unknown column 'genres_id' in 'on clause' 0.000 sec"
Could someone please advise what statement I would require to solve this error being returned?
I have attempted adding it myself:
3 32 14:15:04 ALTER TABLE genres ADD COLUMN genres_id INTEGER 0 row(s) affected Records: 0 Duplicates: 0 Warnings: 0 0.078 sec
I would guess that it is completely wrong as when I use the statement from the video:
SELECT * FROM movies JOIN genres ON movies.genre_id = genres_id;
There are absolutely no values returned across the 7 columns (id, title, year, genre_id, id, name, genres_id)
It would be much appreciated if someone could help me out. Thank you in advance.
Jason AndersTreehouse Moderator 145,627 Points
ALTER TABLE movies ADD COLUMN genre_id INTEGER NULL, ADD CONSTRAINT FOREIGN KEY (genre_id) REFERENCES genres(id);
Hope that works. :)