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!

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

PHP Integrating PHP with Databases Using Relational Tables Querying Multiple Tables with JOIN

Artan Muzhaqi
Artan Muzhaqi
7,983 Points

The code doesn't work. Unable to retrieve results SQLSTATE[HY000]: General error: 1 ambiguous column name: media_id

i copied everything from the video but on mine it doesn't work.

1 Answer

Hey Artan!

You're right - in the video, the query written is incorrect. From what I understand, she's joining on "media_id" in the video, when it should be joining on "genre_id".

Try this SELECT statement and it should work!

  "SELECT title, category, img, format, year, 
      publisher, isbn, genre
      FROM Media
      JOIN Genres ON Media.genre_id=Genres.genre_id
      LEFT OUTER JOIN Books 
      ON Media.media_id = Books.media_id
      WHERE Media.media_id = $id"

Hope that works for you!

This was perfect, Thank you!!

Hey Alex,

Thanks a lot for your answer. This had me stumped for a bit. The course video should be recorded.