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?
views:
32answers:
2
+1
A:
SELECT GROUP_CONCAT(`emailAddress` SEPARATOR ';') AS `emails`
FROM table
WHERE id=4
GROUP BY id
Rocket
2010-10-15 15:46:19
Damn, beat me to it by 11 whole seconds :) There is however a limit to this string (`group_concat_max_len`)
Wrikken
2010-10-15 15:47:00
I'm nice like that.
Rocket
2010-10-15 15:47:52
+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
2010-10-15 15:47:57