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 trialLuis Manuel Lopez Hidalgo
Full Stack JavaScript Techdegree Student 23,195 PointsNot a question but a comment. I think in the last part of the video what we want is the patron_id and not the id.
I think we need the patron_id because they are the people we are looking to send an email.
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Luis,
I think these are the 2 queries you're referring to:
SELECT * FROM loans WHERE return_by > "2015-12-18";
SELECT first_name, email FROM patrons WHERE id = 1 OR id = 3;
It's correct to use id in the second query because Andrew is querying the patrons table which doesn't have a patron_id column but it does have an id column used as the primary key.
The loans table does have a patron_id column. This is used as a foreign key on the patrons table. It creates a relationship between the 2 tables. The patron_id column in the loans table corresponds to the id column in the patrons table.
With the 1st query Andrew looked at the patron_id column from the loans table to discover that patrons 1 and 3 haven't returned their books yet. Andrew then searches for those id's in the patrons table (using the id column) to get their contact information.
Luis Manuel Lopez Hidalgo
Full Stack JavaScript Techdegree Student 23,195 PointsLuis Manuel Lopez Hidalgo
Full Stack JavaScript Techdegree Student 23,195 PointsThat's right, I miss that detail. Certainly we need to use the patrons table to get the firstname and the email. Thank you!