tags:

views:

32

answers:

2

I need to select all email addresses from a table, but implode them by ;. Is it possible for me to do this only utilizing a single MySQL query?

+1  A: 
SELECT GROUP_CONCAT(`emailAddress` SEPARATOR ';') AS `emails`
FROM table
WHERE id=4
GROUP BY id
Rocket
Damn, beat me to it by 11 whole seconds :) There is however a limit to this string (`group_concat_max_len`)
Wrikken
I'm nice like that.
Rocket
+2  A: 

Yes,

With GROUP_CONCAT. But you should be aware that the default maximum returned length is 1024. Follow the link to see how you can work around this limitation (if needed).

Alin Purcaru
+1 for group_concat_max_len, I didn't realize that.
Rocket
I had my returned values trunkated a few times because of that.
Alin Purcaru