SELECT cont.msg_id, cont.msg_text, CONCAT_WS(', ', a1.address, a2.address)
FROM CONTENT AS cont, ADDRESS AS a1, ADDRESS AS a2 WHERE cont.msg_id =
a1.msg_id AND cont.msg_id = a2.msg_id;

Many thanks to salle in efnet #mysql for teaching me this trick ;-)

> Hello,
>
> I am relatively new with MySQL (and SQL for that matter) and I couldn't
> find much reference to my problem in earlier posts.
>
> Let's say I have 2 tables,
>
> CONTENT: msg_id, msg_text
>
> ADDRESS: msg_id, address
>
> and I receive the msg "Hello World" addressed to the twins Foo and Bar.
> now my tables look like this:
>
> CONTENT:
>
> 1     Hello World
>
> ADDRESS:
>
> 1     Foo
> 1     Bar
>
> I am desperatly looking for a sql statement that would produce
>
> 1     |       Hello World     |       Foo, Bar
>
> Is there such a thing??


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to