group_concat MYSQL new line

I don't understand what do you mean by line break between X and Y, but if you need the values to be comma separated you can add any separator to the Group_Concat like that:

group_concat(Name SEPARATOR ' ') as Name

and here is some other separators you can use.


I figured it out. this is the correct way to add line break as seperator in the browser:

group_concat(A,' ',B,' ',C separator '<br>') as Name,

For MySQL (or plain text) output You could use \n as a separator:

SELECT GROUP_CONCAT(column1 SEPARATOR '\n') FROM table1;

I use this very often when I need to get many new-line-separated values in one row for other processing.

Tags:

Mysql

Php