473,395 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using many to many tables

I'm having a problem writing the correct sql to bind togeather three
tables. Here's the problem: I have a table for detail information on
books that are in our catalog, and a table for authors. Unfortunatly, it
is not a one to one relationship. Some books are written by several
authors, hence, I've created an intermidiate table called book_to_author
where I list the isbn's for the books next to the author id's, so I may
list an isbn three times with three different author id's next to it, if
three authors have contributed to it.

Now I have to write a sql statement that will pull up the book detail
info, such as the title, and the three authors associated with it.
Assuming I have a table called authors, with an author name in it, one
called book_to_authors, with the isbn and author_id, and a third called
books, with the title in it, how would I write the sql to join all the
info where the isbn='0530725318?

Thanks a million if you can help. I've been trying to write this all
morning, and can't get it to work.

Bill

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 3884
Hi

Something like the following should do!!

SELECT B.Title, A.Name
FROM Books B JOIN Books_To_Authors C ON C.ISBN = B.ISDB
JOIN Authors A ON C.AuthorId = A.Authorid
If you are actually wanting a crosstab query here are a list of useful
links:
http://tinyurl.com/i9mt
John
"Bill" <Bi***********@gospellight.com> wrote in message
news:3f***********************@news.frii.net...
I'm having a problem writing the correct sql to bind togeather three
tables. Here's the problem: I have a table for detail information on
books that are in our catalog, and a table for authors. Unfortunatly, it
is not a one to one relationship. Some books are written by several
authors, hence, I've created an intermidiate table called book_to_author
where I list the isbn's for the books next to the author id's, so I may
list an isbn three times with three different author id's next to it, if
three authors have contributed to it.

Now I have to write a sql statement that will pull up the book detail
info, such as the title, and the three authors associated with it.
Assuming I have a table called authors, with an author name in it, one
called book_to_authors, with the isbn and author_id, and a third called
books, with the title in it, how would I write the sql to join all the
info where the isbn='0530725318?

Thanks a million if you can help. I've been trying to write this all
morning, and can't get it to work.

Bill

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ben Jessel | last post by:
I am in the process of converting my site to using XHTML and CSS. A lot of my sites include tables of data, which are highlighted using javascript rollovers. I have converted my a lot of my...
21
by: BT | last post by:
I inherited a simple page that needs to be Strict HTML and I'm not very familiar with this standard. What I'm trying to do _should be_ pretty simple so I hope someone can point me in the right...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
3
by: Eric | last post by:
Help! I created a XML schema with a Visual Studio tools. I'm filling a dataset with a DataAdapter. Before I use the "WriteXml" method to write the data to a xml file, I want to map the XSD file I...
4
by: lesperancer | last post by:
it looks like this will save many versions of a relationship window, but based on the fact that the same tables are displayed in the relationship window and it will restore versions of what was...
7
by: Ryan | last post by:
Quite awile ago I posted to this newsgroup in regards to using Datasets in my VB 2005 application. About how many Datasets should be used.. a limit to the number of tables that should be included...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.