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

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

PHPz
PHPzforward
2023-09-16 13:05:021125browse

在 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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete