Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sql splicing multiple information in the same field

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report