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

The method of mysql parallelism

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Editor to share with you the method of mysql parallel, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Mysql concurrency method: use the function [GROUP_CONCAT ()] with the code [SELECT am.activeId,GROUP_CONCAT (m.modelName SEPARATOR',') modelName].

The parallel method of mysql:

A field may correspond to multiple pieces of data. Use mysql to merge multiple rows of data into one row of data.

For example, an active id (activeId) corresponds to multiple module names (modelName), according to the general sql statement:

1 SELECT am.activeId,m.modelName 2 FROM activemodel am 3 JOIN model m 4 ON am.modelId = m.modelId 5 ORDER BY am.activeId

The list of queries is shown in figure 1:

Figure 1

The modified sql statement is shown in figure 2 after the query:

1 SELECT am.activeId,GROUP_CONCAT (m.modelName SEPARATOR',') modelName2 FROM activemodel am 3 JOIN model m 4 ON am.modelId=m.modelId5 WHERE m.valid=16 GROUP BY am.activeId

It is important to note:

The value in 1.GROUP_CONCAT () is the field name of the data you want to merge.

The SEPARATOR function is used to separate the data to be merged.

Which symbol do you want to use to separate it

two。 Grouping must be managed with GROUP BY statements, otherwise all data will be merged into a single record, as shown in figure 3

Figure 2

Figure 3

The above is all the contents of the mysql parallel method, thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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