"Klaas Geldof" <[EMAIL PROTECTED]> wrote:
>
> I have a question about MySQL queries. First I will explain the situation,
> then I will provide an example.
>
>
> Situation:
>
> I have the tables 'offer', 'contact' and 'offer_contact'. Table 'offer'
> contains data about offers, table 'contact' about contacts. Table
> 'offer_contact' tells which contacts are associated with which offers (since
> offers can have multiple contacts associated with it and vice versa). Now I
> want to run a query so I get a row for each offer and in the result there's
> a field 'offer_contacts' which contains all the names of the contacts
> associated with the offer on that row separated by comma's.
>
>
> Example:
>
> Table 'offer' (offer_id - offer_title):
> 1 - Test
> 2 - Also test
>
> Table 'contact' (contact_id - contact_name):
> 1 - John
> 2 - Anna
>
> Table 'offer_contact' (offer_id - contact_id):
> 1 - 1
> 1 - 2
> 2 - 1
>
> Wanted result of query (offer_id - offer_name - offer_contacts):
> 1 - Test - John, Anna
> 2 - Also test - John
>
>
> Is this possible?
>
GROUP_CONCAT() function may help. This function is available from version 4.1:
http://dev.mysql.com/doc/mysql/en/GROUP-BY-Functions.html
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Victoria Reznichenko
/ /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED]
/_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net
<___/ www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]