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.

PHP

Luke McGuigan
Luke McGuigan
14,228 Points

Trouble with challenge 2 of Multiple Conditionals (Integrating PHP with Databases)

Hello, the following is the SQL query I've used for this task, whilst it's pulling only the title from the media title in regards to the lastname of 'Tolkien', it seems the issue where this isn't being accepted if that duplicates of each item are being produced.

SELECT title FROM Media me JOIN Media_People m, People p ON m.people_id = p.people_id WHERE fullname LIKE '%Tolkien';

I was wondering if anyone could provide assistance on this.

Thanks

Simon Coates
Simon Coates
28,693 Points

can you add a link to the challenge this is in reference to?

3 Answers

Simon Coates
Simon Coates
28,693 Points
SELECT m.title FROM Media m
    JOIN Media_People mp ON m.media_id = mp.media_id
    JOIN People p ON mp.people_id = p.people_id
  WHERE p.fullname like '%Tolkien';
Luke McGuigan
Luke McGuigan
14,228 Points

Thank you for your assistance, that worked wonderfully, I need to reconsider how I write SQL queries.

Luke McGuigan
Luke McGuigan
14,228 Points

It's just an alias to reference the Media table, though it may be redundant here, regardless I received the same result without it.

Does anybody know the answer to task 3 of this same challenge? Really struggling on that one

Simon Coates
Simon Coates
28,693 Points

Given the URL provided, the third part looks something like:

SELECT m.title FROM Media m
    JOIN Media_People mp ON m.media_id = mp.media_id
    JOIN People p ON mp.people_id = p.people_id
  WHERE p.fullname like '%Tolkien' and m.category = "Books"