I can't come up with a query that works. Can anyone help?
Conceptually the relationships are easy to describe. I have
a table for books (Entries), a table for authors (Authors),
and a linking table between the two because books often
have more than one author (OA_Link). This situation is
simple and common. A query to list each title and all
the authors associated with that title looks like this:
SELECT Entries.TitleSt atement, Authors.AuthorN ame
FROM Authors
INNER JOIN (Entries INNER JOIN OA_Link
ON Entries.EntryID = OA_Link.OA_Entr yID)
ON Authors.AuthorI D = OA_Link.OA_Name ID
WHERE Authors.AuthorN ame Like "*Twain*";
Unfortunately there is an added twist which I can't
resolve. There is also present the concept of the
"Main Author." The single individual who holds primary
responsibility for the book. The designer of the
database chose to create a one-to-one link directly
from Entries to Authors without going through the
linking table. With the query above, I can only retrieve
books which have "Twain" as an added author, but not
when Twain is the principle author. If I do a query
on principle authors only, it looks like this:
SELECT Entries.TitleSt atement, Authors.AuthorN ame
FROM Authors INNER JOIN Entries
ON Authors.AuthorI D = Entries.AuthorI D
WHERE Authors.AuthorN ame Like "*Twain*";
How do I combine the two to do a query that searches
both Authors as Principle Author as well as Authors as
Added Authors? I need a pure SQL solution rather than
something that uses saved queries.
Thanks to anyone who can help me!
Arvin
Conceptually the relationships are easy to describe. I have
a table for books (Entries), a table for authors (Authors),
and a linking table between the two because books often
have more than one author (OA_Link). This situation is
simple and common. A query to list each title and all
the authors associated with that title looks like this:
SELECT Entries.TitleSt atement, Authors.AuthorN ame
FROM Authors
INNER JOIN (Entries INNER JOIN OA_Link
ON Entries.EntryID = OA_Link.OA_Entr yID)
ON Authors.AuthorI D = OA_Link.OA_Name ID
WHERE Authors.AuthorN ame Like "*Twain*";
Unfortunately there is an added twist which I can't
resolve. There is also present the concept of the
"Main Author." The single individual who holds primary
responsibility for the book. The designer of the
database chose to create a one-to-one link directly
from Entries to Authors without going through the
linking table. With the query above, I can only retrieve
books which have "Twain" as an added author, but not
when Twain is the principle author. If I do a query
on principle authors only, it looks like this:
SELECT Entries.TitleSt atement, Authors.AuthorN ame
FROM Authors INNER JOIN Entries
ON Authors.AuthorI D = Entries.AuthorI D
WHERE Authors.AuthorN ame Like "*Twain*";
How do I combine the two to do a query that searches
both Authors as Principle Author as well as Authors as
Added Authors? I need a pure SQL solution rather than
something that uses saved queries.
Thanks to anyone who can help me!
Arvin
Comment