forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
8.7 KiB
8.7 KiB
concat_ws
This function is used to return a string concatenated from multiple input strings that are separated by specified separators.
Syntax
concat_ws(string <separator>, string <str1>, string <str2>[,...])
or
concat_ws(string <separator>, array<string> <a>)
Returns the result of joining all the strings in the parameters or the elements in an array using a specified separator.
Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
separator |
Yes |
STRING |
Separator of the STRING type |
str1, str2 |
Yes |
STRING |
At least two strings must be specified. The value is of the STRING type. If the value is of the BIGINT, DECIMAL, DOUBLE, or DATETIME type, the value is implicitly converted to the STRING type for calculation. |
a |
Yes |
ARRAY |
The elements in an array are of the STRING type. |
Return Values
The return value is of the STRING or STRUCT type.
Example Code
- Use a colon (:) to connect strings ABC and DEF. An example command is as follows:
- The value of any input parameter is NULL. An example command is as follows:The value avg:18 is returned.
select concat_ws(':','avg',null,'18');
- Use colons (:) to connect elements in the array ('name', 'lilei'). An example command is as follows:
Parent topic: String Functions