|
-
Feb 23rd, 2010, 08:40 PM
#1
Thread Starter
Addicted Member
Help with DB Development
Hi guys. I'm sort of having some problem with the way our database's structure is supposed to be like. This concerns books and authors.
Taking the following notes into consideration:
- There can be 1 or more authors of a book
- There can be 1 or more books having the same author
Okay, taking those two things into consideration, this would be the table structure (please don't mind the simpleness of the tables, as they are only used for examples):
[Author]
AuthorID (PK)
AuthorName
[AuthorDetails]
AuthorID, BookID (PK)
[Book]
BookID (PK)
BookTitle
Given this data:
Book Title: MyTitle
Authors: Author1, Author2, Author3
What query should I use to make the query result look like this:
Title AuthorName1 AuthorName2 AuthorName3
MyTitle Author1 Author2 Author3
Because, if I query this statement:
Code:
SELECT Book.BookID AS Expr1, Book.CallNumber AS Expr2, Book.Title AS Expr3, AuthorDetails.BookID, AuthorDetails.AuthorID, Author.AuthorID AS Expr4
FROM Book INNER JOIN
AuthorDetails ON Book.BookID = AuthorDetails.BookID INNER JOIN
Author ON AuthorDetails.AuthorID = Author.AuthorID
GROUP BY Book.BookID, Book.CallNumber, Book.Title, AuthorDetails.BookID, AuthorDetails.AuthorID, Author.AuthorID
It results into the authors being broken down into three separate records, ie:
MyTitle Author1
MyTitle Author2
MyTitle Author3
Anyone?
====================
ほんとにどもありがとう!
Rie Ishida
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|