课程: Hands-On SQL Challenges: Test Your Knowledge

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Check for books due back

Solution: Check for books due back

- [Instructor] This challenge asked us to prepare a report of books that are due to be returned or which are overdue on a specific day. In order to find which books are due back on a given day, we'll use a select statement and we'll need to use the due date field from the loans table. We'll also need the book title and some patron information. The first field I'm using is from the loans table, so I'll add from loans. You don't have to use the first table you reference as the from condition, but it helps keep things organized. And depending on how you prefer to write queries, you might use aliases to provide shorter names for each table here. In this query, I've left the table names alone, so we can see what we're doing more easily. We'll also need information from the books table, so I'll join that and set the book ID field in the loans table to match up with the book ID field in the books table. And then we'll need patron information as well. So I'll add join patrons and say that the…

内容