MySQL multi-line Merge one column uses the function as:
GROUP_CONCAT (exp)
The parameters of exp are similar to the following:
(Field order BY field desc separator '; ') );
The specific examples are as follows:
To create a table:
CREATE TABLE' login ' (' Id ' )int( One) not NULLauto_increment, ' name 'varchar(255)DEFAULT NULL, PRIMARY KEY(' Id ')) ENGINE=MyISAM auto_increment=7 DEFAULTCHARSET=Gbk
Add Data:
Insert intoLogin (Id,name)Values(3,'Dalong');Insert intoLogin (Id,name)Values(4,'Dalong');Insert intoLogin (Id,name)Values(5,'Dalong');Insert intoLogin (Id,name)Values(6,'Dalong');Insert intoLogin (Id,name)Values(7,'app');Insert intoLogin (Id,name)Values(8,'app');Insert intoLogin (Id,name)Values(9,'app');
Test results:
Sort by name to get the combination of IDs:
SQL is as follows:
Select Name,group_concat (ID orderbydesc'; ') from Group by name;
Test results:
MySQL multi-line merge one column