Basic syntax: Group_concat ([DISTINCT] field to connect [order by sort field Asc/desc] [Separator ' delimiter '])
Initial data:
Group by name, print money on one line, default ', ' delimited:
Select AA. ' Name ' name, Group_concat (money) money from the AA GROUP by AA. ' Name '
Group by name, print money on one line, separated by '; '
Select AA. ' Name ' name, Group_concat (Money separator '; ') money from the AA GROUP by AA. ' Name '
Group by name, remove redundant money, separate with '; '
Select AA. ' Name ' name, Group_concat (DISTINCT money separator '; ') money from the AA GROUP by AA. ' Name '
parameter setting and restriction description
1. View settings on the server
Mysql> Show variables like '%group_concat% '; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | Group_concat_max_len | 1024x768 | +----------------------+-------+ 1 row in Set (0.00 sec)
The value of the above setting indicates that the default length is currently 1KB
2. Changing parameter values
Method One: Modify the parameters in the configuration file, add Group_concat_max_len = 10240
Method Two: Implemented in session, global or current session
SET GLOBAL group_concat_max_len=10240;
SET SESSION group_concat_max_len=10240;
Group_concat () usage in MySQL