MySQL: Show Results Of A Column As 1 Line

Say, your sql result will return multiple rows that may look something like this

id email
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 email
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.


(No Ratings Yet)
 Loading ...

tags: ,

Leave a Reply