CONCAT (str1,str2,...) NULL.
Mysql> SelectConcat' One',' A',' -');+------------------------+|Concat' One',' A',' -')|+------------------------+| 112233 |+------------------------+
Mysql> SelectConcat_ws (',',' One',' A',' -');+-------------------------------+|Concat_ws (',',' One',' A',' -')|+-------------------------------+| One, A, - |+-------------------------------+
Group_concat ([DISTINCT]The field to connect to[ORDER by Asc/desc sort field] [Separator ' delimiter ']) basic query MySQL> Select * fromAA;+------+------+|Id|Name|+------+------+|1 | Ten||1 | -||1 | -||2 | -||3 | $ ||3 | - |+------+------+6Rowsinch Set(0.00sec) Group by ID, print the value of the Name field on one line, comma separated (default) MySQL> SelectId,group_concat (name) fromAaGroup byID;+------+--------------------+|Id|Group_concat (name)|+------+--------------------+|1 | Ten, -, -||2 | - ||3 | $, -|+------+--------------------+
GROUP by ID, print the value of the Name field in one line, comma-delimited, and reverse-order in the name column MySQL> SelectId,group_concat (nameOrder byNamedesc) fromAaGroup byID;+------+---------------------------------------+|Id|Group_concat (nameOrder byNamedesc)|+------+---------------------------------------+|1 | -, -,Ten ||2 | -||3 | -, $|+------+---------------------------------------+
GROUP by ID, print the value of the Remove redundant name field in one line, comma separated MySQL> SelectId,group_concat (distinctName fromAaGroup byID;+------+-----------------------------+|Id|Group_concat (distinctName|+------+-----------------------------+|1 | Ten, -||2 | - ||3 | $, - |+------+-----------------------------+
MySQL concat concat_ws group_concat function (connection string)