Re: Many-to-many query question

From: Mike MacSween <mike.macsween.nospam_at_btinternet.com>
Date: Sat, 7 Feb 2004 19:31:46 -0000
Message-ID: <40253d22$0$4104$5a6aecb4_at_news.aaisp.net.uk>


There's a product made by Microsoft called Access. It's a sort of file processor I believe. That has something called Crosstab queries that does what you want.

Mike

"Jonck van der Kogel" <jonck_at_vanderkogel.net> wrote in message news:28a69e7c.0402011530.2f493fc1_at_posting.google.com...
> Hi everybody,
> I have a question on a query involving a many-to-many relationship
> that I can't seem to figure out, I was hoping that one of you might be
> willing to lend me a hand with this.
>
> I will give a simple example here, my real life problem is with a lot
> more tables, but once I have the answer to this "simple" example I'll
> be able to translate the solution to my
> more-difficult-to-explain-briefly problem.
>
> Let's say you have books and authors. An author can have written many
> books and a book can have many authors. So I could have three tables
> as follows:
>
> author_id | author_name
> 1 | Edwards
> 2 | Williams
> 3 | Winston
>
>
> book_id | book_name
> 1 | MySQL
> 2 | PHP
> 3 | Apache
>
> And then the joining table:
>
> join_id | book_id | author_id
> 1 | 1 | 1
> 2 | 1 | 2
> 3 | 2 | 1
> 4 | 2 | 3
> 5 | 3 | 3
>
> Now let's say I wan't to query for all the authors of book #1.
> Naturally this is very simple to do, but every way I think of returns
> two rows, whereas what I am looking for is to get this information in
> a single row. Can this be done?
>
> Thanks for any help, Jonck
Received on Sat Feb 07 2004 - 20:31:46 CET

Original text of this message