CONCAT_WS()
Function Description
CONCAT_WS() represents Concatenate With Separator and is a special form of CONCAT(). The first parameter is the separator for other parameters. The position of the separator is placed between the two strings to be connected. The delimiter can be a string or other parameters. If the delimiter is NULL, the result is NULL. The function ignores the NULL value after any delimiter parameter.
Function Syntax
- Function Syntax 1
> CONCAT_WS(separator,str1,str2,...)
- Function Syntax 2
> CONCAT_WS(separator,str1,NULL,str1,...);
Parameter definition
| Parameters | Description |
|---|---|
| Str | Required parameters. A string that needs to be flipped. Both CHAR and VARCHAR types are available. |
Example
SELECT CONCAT_WS(',','First name','Second name','Last Name');
+---------------------------------------------------------------------+
| concat_ws(,, First name, Second name, Last Name) |
+---------------------------------------------------------------------+
| First name,Second name,Last Name |
+---------------------------------------------------------------------+
1 row in set (0.01 sec)
> SELECT CONCAT_WS(',','First name',NULL,'Last Name');
+-------------------------------------------------------+
| concat_ws(,, First name, null, Last Name) |
+-------------------------------------------------------+
| First name,Last Name |
+-------------------------------------------------------+
1 row in set (0.01 sec)