Home > Database > Mysql Tutorial > In MySQL, how to combine two or more strings with delimiter?

In MySQL, how to combine two or more strings with delimiter?

PHPz
Release: 2023-09-16 13:05:02
forward
1176 people have browsed it

在 MySQL 中,如何将两个或多个字符串与分隔符组合在一起?

In MySQL, we can use the CONCAT_WS() function to combine two or more strings with a delimiter. The syntax of this function is CONCAT_WS(Separator, String1,String2,…,StringN)

Here, the parameters of the CONCAT_WS function are the Separator and the string that needs to be connected. The separator is treated as a single character. string. Delimiters other than numeric values ​​must be enclosed in quotes.

Example

mysql> Select CONCAT_WS('.','www','tutorialspoint','com');
+---------------------------------------------+
| CONCAT_WS('.','www','tutorialspoint','com') |
+---------------------------------------------+
| www.tutorialspoint.com                      |
+---------------------------------------------+
1 row in set (0.00 sec)
Copy after login

In the above example, we can see that the separator "." (i.e. dot) is inserted between the three strings that need to be concatenated (www, tutorialspoint and com) between.

The above is the detailed content of In MySQL, how to combine two or more strings with delimiter?. 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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template