I am trying to think of SQL that will let me show a one to many relationship
as a single row in a result set. They say a picture is worth a thousand
words so let me draw that picture.

Event_ID    Event_Name    etc.
1               Concert
2               Art Exhibit
3               Spelling Bee
[Primary key: Event_ID]


Event_ID    File_Number    File
1               1                    promoter_logo.jpg
1               2                    venue_logo.jpg
1               3                    performer_graphic.jpg
2               1                    artist_graphic.jpg
[Primary Key: Event_ID, File_Number]


Desired Result:
Event_ID    Event_Name    File                            File
File
1               Concert           promoter_logo.jpg      venue_logo.jpg
performer_graphic.jpg
2               Art Exhibit        artist_graphic.jpg
3               Spelling Bee


There is one record in the Events table for each event that an organization
is promoting. For each event, there could be 0 to 'n' files that give more
information about the event, such as pictures, audio clips, or whatever. I
want to display all the information about the event, including all of the
file names for that event, on a single result set row for each event,
regardless of how many files exist for that event. [At the moment, there is
a limit of 3 files per event but that could increase.]

Can anyone suggest a query that would do what I need to do?


Rhino
---
rhino1 AT sympatico DOT ca
"There are two ways of constructing a software design. One way is to make it
so simple that there are obviously no deficiencies. And the other way is to
make it so complicated that there are no obvious deficiencies." - C.A.R.
Hoare


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to