one, concat () function can connect one or more strings
CONCAT (STR1,STR2,...) returns the string produced by the result of the connection parameter. If any of the arguments are null, the return value is null.
Select Concat (' 11 ', ' 22 ', ' 33 ');
Query results show: 112233
ii. Concat_ws (separator,str1,str2,...)
is a special form of concat (). The first parameter is the separator for the other arguments. The position of the separator is placed between the two strings to which you want to connect. The delimiter can be a string, or it can be another parameter.
Select Concat_ws (', ', ' 11 ', ' 22 ', ' 33 ');
Query Display results: 11,22,33
three, Group_concat () group splicing function
Group_concat ([DISTINCT] The field to connect [order by Asc/desc sort field] [Separator ' delimiter]]
Use Group_concat () for one of the following sets of data
| ID |name
|1 | 10|
|1 | 20|
|1 | 20|
| 20|
|3 | 200 |
|3 | 500 |
1, select Id,group_concat (name) from AA Group by ID;
|1 | 10,20,20|
| 20 |
|3 | 200,500|
2, select ID,GROUP_CONCAT (name separator '; ') from the AA group by ID;
|1 | 10;20;20 |
| 20|
|3 | 200;500 |
3, select ID,GROUP_CONCAT (name order BY name Desc) from the AA group by ID;
|1 | 20,20,10 |
| 20|
|3 | 500,200|
4, select Id,group_concat (distinct name) from AA Group by ID;
|1 | 10,20|
| 20 |
|3 | 200,500 |