Reputation: 62394
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?
Upvotes: 3
Views: 6719
Reputation: 44346
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).
Upvotes: 6
Reputation: 227260
SELECT GROUP_CONCAT(`emailAddress` SEPARATOR ';') AS `emails`
FROM table
WHERE id=4
GROUP BY id
Upvotes: 6