Vote count:
0
I am very new to SQL and I'm attempting to work through some exercises and I am having some trouble with the following problem:
There is a database consisting of six tables:
Author(AUTHOR ID, AUTHOR NAME, AUTHOR FIRSTNAME)
Book(BOOK ID, ISBN, TITLE, EDITOR, EDITION DATE) which contains the list of books (ISBN attribute is the key).
Written(AUTHOR ID, BOOK ID) which is the list of books written by each author.
Copy(BOOK ID, COPY ID, STATUS, ACQ DATE) which contains the list of copies for each book.
Borrower(USER ID, USER NAME, USER FIRSTNAME, USER ADDRESS) which contains the list of borrowers.
Borrowing(BOOK ID, COPY ID, USER ID, BORROWING DATE) which contains the list of borrowing in the library.
With these tables I am trying to accomplish a few queries:
Search the titles of books written by Ernest Hemingway
Search the id, name and first name of borrowers which borrow the book with id 10
Search the number currently borrowing.
Then for each book, search the id, title and number of copies which have the status borrowed
For the first one I used: SELECT title FROM Book WHERE Author='Ernest Hemingway
For the thrid: SELECT COUNT(DISTINCT book id) FROM Borrowing
I'm a little stumped on the remaining two (I'm a little confused on the join method) and I wanted to make sure these other two queries were correct as well. Any help is much appreciated.
Thanks guys!
SQL Join and select
Aucun commentaire:
Enregistrer un commentaire