MySQL: Show Results Of A Column As 1 Line
Posted by tech on
February 1, 2009
Say, your sql result will return multiple rows that may look something like this
| id | |
| 1 | email1@email.com |
| 1 | email2@email.com |
There is a pretty useful MySQL function that displays the email addresses found in the 2 rows as one. Using the GROUP_CONCAT(), e.g. GROUP_CONCAT(column_name separator_character) maybe result in something like this
| id | |
| 1 | email1@email.com email2@email.com |
The syntax used was SELECT id, GROUP_CONCAT(email, ‘ ‘) …
You can use any other character like comma.
No TweetBacks yet. (Be the first to Tweet this post)
Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.






