Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove separator in group_concat in mysql

Tags:

mysql

In mysql query am using grpup_concat function to concatenate the rows. It resulting the correct values but it is adding separator. for ex: my result for specified column as below.

{10,20}|,{20,30}|,{40,50} // pipe symbol i have added as a separator but it is again adding comma as a separator.

desired result: {10,20}|{20,30}|{40,50}

let me know how to remove the separator. Thanks in advance.

like image 944
SNG Avatar asked Dec 20 '25 03:12

SNG


1 Answers

Whatever you need as s separator, specify after SEPARATOR keyword just like below:

SELECT GROUP_CONCAT(field_name SEPARATOR '|') FROM table_name

like image 133
sushil Avatar answered Dec 22 '25 18:12

sushil