Digital Marketing

MySQL GROUP_CONCAT() function returns a string result with the comma(,) concatenated non-NULL values from a group

GROUP_CONCAT() function (AKA poor man's window function) returns a string result with the comma(,) concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values.

You can use GROUP_CONCAT() to concatenate multiple MySQL rows into one field.

For the following table i88ca:

idemailidemail_tagid
50922777669
50822777674
51122777678
51222777681
51022777684
51722876769
51622876777
51322876779
51422876781
51522876784
select emailid, group_concat(email_tagid) from i88ca group by emailid;
returns:
emailidgroup_concat(email_tagid)
22777669,74,78,81,84
22876769,77,79,81,84

More options:
select emailid, group_concat(distinct email_tagid order by email_tagid asc separator ' ') from i88ca group by emailid;
returns:
emailidgroup_concat(distinct email_tagid order by email_tagid asc separator ' ')
22777669 74 78 81 84
22876769 77 79 81 84

Comments

Popular posts from this blog

Make online money from the Internet