Sql splicing multiple information in the same field
Write down what you inadvertently use today.
such as
T_Stu_Hobby student interest table. Associate the student table and the interest table. Many-to-many relationship
Stu_ID Hobby_ID
=
1 1
1 2
1 3
2 1
2 2
How to get such a result:
Stu_ID Hobby_ID
1 '1jue 2jin3'
2 '1par 2'
More 0
Now there is a user table, a role table, and a table that connects users and roles. I query the information of users, but this user has multiple roles, multiple tables query, and the same user has multiple roles. Concatenate the results of these role fields in the role field.
Select group_concat (the fields you want to merge) what is the grouping of the from table group by
Can be realized.