MySQL string concatenation (function)

Recently, I helped process data and needed to update data in batches, so I checked the method online and recorded it here. My raw data is as follows:

1. CONCAT() function
Explanation: CONCAT(string1, string2, string3...), here is to seamlessly concatenate strings such as string1, string2 and string3, etc., and the returned result is a string generated by concatenating parameters. If any parameter is NULL, the return value is NULL.
A. seamless connection

B. If any value is NULL, return NULL

2. CONCAT_WS() function
description: CONCAT_WS(separator, string1, string2, string3...), here is to directly splice strings such as string1, string2 and string3 with a special string separator, and the returned result is generated by the connection parameters string. CONCAT_WS() stands for CONCAT With Separator, which is a special form of CONCAT(). The first parameter is the delimiter for other parameters. The position of the delimiter is placed between the two strings to be concatenated. The delimiter can be a string or other parameters. If the delimiter is NULL, the result is NULL.
A. Special character concatenation

B. This method parameter can be NULL

C. If the delimiter is NULL, the result is NULL

3. GROUP_CONCAT () function
Description: GROUP_CONCAT ([DISTINCT] field to be connected [Order BY sort field ASC/DESC] [Separator 'separator']).
A. Group by class_id, print out the values ​​of the weights field on the same line, separated by commas (default)

B. Group by class_id, print out the values ​​of the weights field on one line, separated by semicolons


C. Group by class_id, and print the values ​​of the weights field in one line, separated by commas


D. Group by class_id, print the values ​​of the weights field on one line, separate them with commas, and arrange them in reverse order according to the weights

at last

I know that most junior and middle-level Java engineers want to improve their skills, and they often try to grow by themselves or enroll in classes. However, the tuition fees of nearly 10,000 yuan for training institutions are really stressful. The effect of self-study is inefficient and long, and it is easy to hit the ceiling and stagnate in technology!

Therefore, I collected and sorted out a " Complete Set of Learning Materials for Java Development " and gave it to everyone. The original intention is also very simple, that is, I hope to help friends who want to learn and improve themselves but don't know where to start, and at the same time reduce everyone's burden.

The editor has encrypted: aHR0cHM6Ly9kb2NzLnFxLmNvbS9kb2MvRFVrVm9aSGxQZUVsTlkwUnc==For security reasons, we have encoded the website through base64, and you can decode the URL through base64.

Guess you like

Origin blog.csdn.net/m0_67265464/article/details/126803294