Home > Database > Mysql Tutorial > body text

What is the use of the MySQL CONCAT_WS() function?

PHPz
Release: 2023-08-26 11:09:18
forward
1312 people have browsed it

MySQL CONCAT_WS() 函数有什么用?

Basically, MySQL CONCAT_WS() function is used to concatenate two or more strings along with the delimiter. The keyword WS in CONCAT_WS() here represents WITH SEPARATOR. We can pronounce the CONCAT_WS() function as a concatenation function with delimiters.

grammar

CONCAT_WS(Separator, String1,String2,…,StringN)
Copy after login

Here, the parameters of the CONCAT_WS function are the delimiter and the string that needs to be concatenated with the delimiter into a single string. Delimiters other than numeric values ​​must be enclosed in quotes.

Example

mysql> SELECT CONCAT_WS(' ','New', 'Delhi');

+-------------------------------+
| CONCAT_WS(' ','New', 'Delhi') |
+-------------------------------+
| New Delhi                     |
+-------------------------------+

1 row in set (0.00 sec)
Copy after login

In the above example, we can see that the string " " (i.e. space) is used as a separator and inserted between the two strings (New and Delhi) that need to be concatenated.

mysql> SELECT CONCAT_WS(' is our ','Delhi','Capital');

+-----------------------------------------+
| CONCAT_WS(' is our ','Delhi','Capital') |
+-----------------------------------------+
| Delhi is our Capital                    |
+-----------------------------------------+

1 row in set (0.00 sec)
Copy after login

In the above example, we can see that the string "is our" is inserted as a separator between the two strings Delhi and Capital that need to be concatenated.

The above is the detailed content of What is the use of the MySQL CONCAT_WS() function?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!