Hi, I'm having a problem on how to query from the following tables. Here are the tables.
PATIENT:
PK - PatientNo
- FirstName
- LastName
- MiddleName
- Address
- Age
FK - PageNo
PAGE
PK - PageNo
BOOK
PK - BookNo
BOOKPAGE 'Junction Table
PK - BookNo
PK - PageNo
Business Rules:
1. A book can contain many pages, and each page can belong to different books.
Example: Book 1 contains pages 1, 2, 3, etc.
Book 2 contains pages 1, 2, 3, etc.
2. Each Page contains different information about patients and a patient only can be listed in one page on a certain book.
Example: Book 1 contains Patient 1 and 2 on Page 1.
Book 1 contains Patient 3 and 4 on Page 2.
Book 2 contains Patient 5 and 6 on Page 1.
Book 2 contains Patient 7 and 8 on Page 2.
'Here a patient cannot be listed more than once in a book and a page.
'I've attached a screenshot on the ER-Diagram.
What I want is to query the list of patients that belongs to a certain book no. How can I arrive with that answer? What is the correct SQL statement to be used? I used this SQL statement,
"SELECT * FROM PATIENT INNER JOIN PAGE ON ([PATIENT].[PageNo]=[PAGE].[PageNo]) WHERE [BOOK].[BookNo] = '" + BookValue + "'"
but I am encountering this error message: "The current row is not available."
And I'm not sure if my SQL statement is right. Please help me. Thanks.