MySql merges a field in a record
One merges a field in a single record: concat ()
For the user table, it is as follows:
Idclassnameage11001zh1821001en1931002cs1841002jp19
If you want to display name and age as a field, there are:
Select id, class, concat (name, ":, age) as name_age from user
Results:
Idclassname_age11001zh:1821001en:1931002cs: 1841002jp: 19
Second, merge some fields in multiple records: group_coacat ()
Still for the above user table, if you group according to grade and merge all name and age into one column, there are:
Select class, group_concat (name, ":", age) as name_age from user group by class
The result is:
Classname_age1001zh:18,en:191002cs:18,jp:19
By default, the group_coacat () method is split with ",". If you want to split with other characters, you can use "separator", such as:
Select class, group_concat (name, ", age separator"; ") as name_age from user group by class
The result is:
Classname_age1001zh:18;en:191002cs:18;jp:19