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.
Task 2 of 3
Here's my query: SELECT title FROM Media JOIN People ON Media.media_id = People.people_id LEFT OUTER JOIN Media_People ON Media.media_id = Media_People.media_id AND People.people_id = Media_People.people_id WHERE People.fullname LIKE '%Tolkien';
What is wrong??
Jennifer NordellTreehouse Teacher
Hi there, George Stathoulias ! First, you need two
INNER joins. So you won't need
LEFT OUTER JOIN. You have some combination here where you're trying to do the
media_id = people_id from different tables. But the
media_id in one table should be equal to the
media_id recorded in the other table. The same thing goes for
media_id. The Media_People table is just a table with two columns. Each column has a list of integers. One column is for the
people_id and the other column is for the
media_id. Assuming the person was "Tom Hanks" and their
people_id was 3, I'm expecting that "Media_People" table to have quite a number of entries where the
people_id is 3 and each movie he's been in is recorded with its
media_id which then looks up the title of the movie in the Media table.
This was my solution:
SELECT title FROM Media JOIN Media_People ON Media_People.media_id = Media.media_id JOIN People ON People.people_id = Media_People.people_id WHERE fullname LIKE '%Tolkien';
Note that the media_id in the joining table matches the media_id in the Media table and the person_id in the joining table matches the person_id in the Person table.
Hope this helps!
Thank you Jennifer. You made things clear!