This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12712|Reply: 1

[Source] Result splicing in mysql

[Copy link]
Posted on 11/1/2018 5:27:55 PM | | |
String splicing in mysql cannot be used +, + can only be used to add numbers.

To connect strings, you can only use concat or concat_ws

(1)concat

1. Function

Stitch multiple results together as strings           

2. Grammar

3. Examples


4. Attention

If one of the strings to be concatenated is null, then the return result is null

So, we usually use IFNULL in conjunction with it


This way, if is_admin is null, then the user_name is returned

(2)concat_ws

1. Function

Stitch multiple results together, using the specified separator

2. Grammar



3. Examples

4. Attention

If there is null in the string to be spliced, the return result will not be null

(3)group_concat

1. Function

Consolidating multi-line strings into a single string in groups must be used in conjunction with groups

2. Grammar



3. Examples
For the whole school student information, the names of the students are spliced together by class







Previous:Postgraduate entrance examination English, postgraduate entrance examination Western medicine comprehensive examination
Next:The Big Bomb (2018)
Posted on 5/28/2022 10:33:40 PM |
Study carefully
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com