At 10:56 AM 6/24/04, Matthias Kritz wrote:
I have the following table structure:

tbl_speakers
        sid
        fname
        lname

tbl_presentations
        pid
        name
        desc

tbl_speakers_presentations
        sid
        pid

I would like to display all presentations, (but each only once), and
display the speakers' names for each presentation. With my current
syntax (see below), if a presentation has, say, 3 speakers I receive 3
distinct records - I just want 1 with 3 speakers columns.


What you are asking for is actually quite complex - my first reaction was to suggest a search through archives for "pivot table" which is the term for making rows into columns. A pivot table would give you three columns for three speakers but your SQL has to be coded for the maximum number of speakers you expect. Also, in this example, a pivot table would still produce three rows, each one with a different speaker in a different column. If you must have *one* row, then you'll need aggregate functions to consolidate the rows. Most examples I've seen of pivot tables are working with numeric fields, so SUM() works quite nicely. I'm not sure what to do about strings though.


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



Reply via email to