I've made a one-to-many table where I have the book isbn matched up to
the author id.
I have a table called books that has the book title, etc. and an author
table that has the author info. I join these to on the book_to_author
table that has two columns, the isbn and the author id, where they match
up.
Now I want to do a search that pulls up all the titles written by one
author, so that if someone sees a book they like on our site, and they
want to pull up all the titles by that author, they click on the authors
name and all the titles they have written now appear on a scroll out
page.
I'm confused about how to write the join statements given the three
tables. So how would I write this?
Thanks for your help,
Bill
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!"Bill" <BillZimmerman@.gospellight.com> wrote in message
news:3f58db68$0$62079$75868355@.news.frii.net...
> I have a book catalog where some books have more than one author, hence
> I've made a one-to-many table where I have the book isbn matched up to
> the author id.
> I have a table called books that has the book title, etc. and an author
> table that has the author info. I join these to on the book_to_author
> table that has two columns, the isbn and the author id, where they match
> up.
> Now I want to do a search that pulls up all the titles written by one
> author, so that if someone sees a book they like on our site, and they
> want to pull up all the titles by that author, they click on the authors
> name and all the titles they have written now appear on a scroll out
> page.
> I'm confused about how to write the join statements given the three
> tables. So how would I write this?
> Thanks for your help,
> Bill
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
It would be helpful to have the DDL (CREATE TABLE) statements for your
tables, but I guess you're looking for something along these lines:
select
b.title
from
dbo.books b
join dbo.book_to_author ba
on b.isbn = ba.isbn
join dbo.authors a
on ba.author_id = a.author_id
where
a.author_id = ???
Simon
No comments:
Post a Comment