Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of mysql parallelism

Shulou Source: shulou.com Published: 2022-06-01 04:29:19 09月10日 Update

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!

Tags: Data methods statements content functions fields articles such as figure merge query one line not much code multiple multiple most more modules knowledge symbols Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Shulou Information Microsoft Redmi