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

Databases

Using 2 Inner Joins at the same time?

How do I use 2 joins at once? I'm getting a syntax error (Missing Operator).

SELECT Rentals.RentalDate, Rentals.Due, Customers.lastname, Customers.firstname, Media.ItemTitle FROM Rentals INNER JOIN Customers ON Rentals.Customer = Customers.ID INNER JOIN Media ON Rentals.Media = Media.ItemTitle WHERE Date() > Rentals.Due;

Steven Parker
Steven Parker
229,732 Points

Can you provide a link to the challenge? The query syntax looks good, but perhaps there's some specific requirement of the challenge that is not being met.

It's a little project I'm working on in Microsoft Access. It's driving me nuts :-P

Steven Parker
Steven Parker
229,732 Points

In that case, can you show the DDL?

1 Answer

Steven Parker
Steven Parker
229,732 Points

Just a wild guess.

Without seeing the challenge, I'm just wondering if that last join should be:

  ... INNER JOIN Media ON Rentals.Media = Media.ID ...

It would make sense if the Media table were constructed like the Customers table.

I did change it to that. It works with either INNER JOIN but not with Both

It turns out the MS Access requires Brackets with multiple join statements.

Thank you for helping me work through it!

SELECT Rentals.RentalDate, Rentals.Due, Customers.lastname, Customers.firstname, Media.ItemTitle FROM ((Rentals INNER JOIN Customers ON Rentals.Customer = Customers.ID) INNER JOIN Media ON Rentals.Media = Media.ID) WHERE Date() > Rentals.Due;

Steven Parker
Steven Parker
229,732 Points

I knew it did that if you use the query builder, but I didn't think they were actually required for it to run.