List:General Discussion« Previous MessageNext Message »
From:SGreen Date:June 24 2004 3:24pm
Subject:Re: JOIN or UNION or both?
View as plain text  
Have you looked at the GROUP_CONCAT() function?

http://dev.mysql.com/doc/mysql/en/GROUP-BY-Functions.html

It returns a string result with the concatenated values from a group. If
you didn't do this you would end up with a ragged-right data set that is
just a nightmare to manage with SQL. In one row you would get 2 columns of
data, in another you could have 10.  This way you end up with two columns,
one of them is a list of values.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



                                                                                          
                            
                      "Matthias Kritz"                                                    
                            
                      <matthiaskritz@gm        To:       <mysql@stripped> 
                                     
                      x.net>                   cc:                                     
                               
                                               Fax to:                                    
                            
                      06/24/2004 10:56         Subject:  JOIN or UNION or both?           
                            
                      AM                                                                  
                            
                                                                                          
                            
                                                                                          
                            




Hi,

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.

//PULL OUT EVERY PRESENTATION WITH A SPEAKER AS SEPERATE RECORD
SELECT *
FROM tbl_presentations, tbl_speakers, tbl_speakers_presentations
WHERE tbl_speakers.sid = tbl_speakers_presentations.sid
AND tbl_presentations.pid = tbl_speakers_presentations.pid

I cant figure out the right JOIN or UNION or AS syntax - still learning
SQL :-)

Any help is greatly appreciated!

Thank you,

Matthias Kritz

_____________________
Digital Samba, S.L.
http://www.digitalsamba.com



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=1






Thread
JOIN or UNION or both?Matthias Kritz24 Jun
  • Re: JOIN or UNION or both?Frank Bax24 Jun
Re: JOIN or UNION or both?SGreen24 Jun
  • RE: JOIN or UNION or both?Matthias Kritz24 Jun
    • Re: JOIN or UNION or both?Markus Grossrieder24 Jun
RE: JOIN or UNION or both?SGreen24 Jun