Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
is it possible?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pasquale  
View profile  
 More options Jun 16 2005, 1:11 am
Newsgroups: mailing.database.mysql
From: Pasquale <spdr...@NOTHNXtelusplanet.net>
Date: Thu, 16 Jun 2005 05:11:57 GMT
Local: Thurs, Jun 16 2005 1:11 am
Subject: is it possible?
With the query below a participant can have more than one event to their
name. Is it possible to have the results somehow group the event names
to each participant or row? So, if the participant is registered for 3
events the row will have his/her name and the 3 event names, rather than
3 rows with their name and each event name.

Thanks.

   SELECT participantID,fname,lname,eventname FROM
   ((((participant as p
   LEFT OUTER JOIN regpartrel as rp ON p.participantID=rp.relparticipantID)
   LEFT OUTER JOIN registration as r ON
rp.relregistrationID=r.registrationID)
   LEFT OUTER JOIN subevent as se ON r.relsubeventID=se.subeventID)
   LEFT OUTER JOIN event as e ON se.releventID=e.eventID)
   WHERE fname LIKE '%brad%'
   GROUP BY p.participantID
   ORDER BY fname, lname, participantID


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aggro  
View profile  
 More options Jun 16 2005, 11:39 am
Newsgroups: mailing.database.mysql
From: Aggro <spammerdr...@yahoo.com>
Date: Thu, 16 Jun 2005 15:39:49 GMT
Local: Thurs, Jun 16 2005 11:39 am
Subject: Re: is it possible?

Pasquale wrote:
> With the query below a participant can have more than one event to their
> name. Is it possible to have the results somehow group the event names
> to each participant or row? So, if the participant is registered for 3
> events the row will have his/her name and the 3 event names, rather than
> 3 rows with their name and each event name.

With temp-tables or subqueries, that should be possible (not sure how to
do that exactly). I personally do that in the application logic usually.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bill Karwin  
View profile  
 More options Jun 16 2005, 12:26 pm
Newsgroups: mailing.database.mysql
From: Bill Karwin <b...@karwin.com>
Date: Thu, 16 Jun 2005 09:26:06 -0700
Local: Thurs, Jun 16 2005 12:26 pm
Subject: Re: is it possible?

Pasquale wrote:
> With the query below a participant can have more than one event to their
> name. Is it possible to have the results somehow group the event names
> to each participant or row? So, if the participant is registered for 3
> events the row will have his/her name and the 3 event names, rather than
> 3 rows with their name and each event name.

If you use MySQL 4.1.6 or higher, MySQL has a grouping function
GROUP_CONCAT().

I haven't used it, but from the docs I believe the usage in your case
would be:

    SELECT p.participantID, p.fname, p.lname,
      GROUP_CONCAT(DISTINCT e.eventname SEPARATOR ', ') AS event_list
    FROM ((((participant as p
      LEFT OUTER JOIN regpartrel as rp
        ON p.participantID=rp.relparticipantID)
      LEFT OUTER JOIN registration as r
        ON rp.relregistrationID=r.registrationID)
      LEFT OUTER JOIN subevent as se
        ON r.relsubeventID=se.subeventID)
      LEFT OUTER JOIN event as e
        ON se.releventID=e.eventID)
    WHERE p.fname LIKE '%brad%'
    GROUP BY p.participantID
    ORDER BY p.fname, p.lname, p.participantID

See http://dev.mysql.com/doc/mysql/en/group-by-functions.html.

Regards,
Bill K.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pasquale  
View profile  
 More options Jun 28 2005, 11:53 pm
Newsgroups: mailing.database.mysql
From: Pasquale <spdr...@NOTHNXtelusplanet.net>
Date: Wed, 29 Jun 2005 03:53:38 GMT
Local: Tues, Jun 28 2005 11:53 pm
Subject: Re: is it possible?

Bill Karwin wrote:
> Pasquale wrote:

>> With the query below a participant can have more than one event to
>> their name. Is it possible to have the results somehow group the event
>> names to each participant or row? So, if the participant is registered
>> for 3 events the row will have his/her name and the 3 event names,
>> rather than 3 rows with their name and each event name.

> If you use MySQL 4.1.6 or higher, MySQL has a grouping function
> GROUP_CONCAT().

Is there an alternative to GROUP_CONCAT() for MySQL 4.0.23?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bill Karwin  
View profile  
 More options Jun 29 2005, 3:54 pm
Newsgroups: mailing.database.mysql
From: Bill Karwin <b...@karwin.com>
Date: Wed, 29 Jun 2005 12:54:04 -0700
Local: Wed, Jun 29 2005 3:54 pm
Subject: Re: is it possible?

Pasquale wrote:
> Is there an alternative to GROUP_CONCAT() for MySQL 4.0.23?

No, there is not.  You either need to upgrade to MySQL 4.1, or else
retrieve your results as you are currently doing, and then manipulate
the result set in your application code.

Not everything can be done in SQL.  Sometimes you just have to write
some code.

Regards,
Bill K.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google