CONCAT_WS
Overview
The CONCAT_WS function is used to concatenate multiple strings or string elements in an array into a single string. The function can concatenate the input strings or string elements in an array based on the specified separator sep. If the input string is NULL, it is ignored in the result.
Syntax
Parameters
sep: Separator string used to join the input strings.str1, str2, ..., strN: Strings to be joined.array1, array2, ..., arrayN: Arrays containing the string elements to be joined.
Return Result
Returns a concatenated string.
Usage Example
- Basic usage:
Results:
- Connecting multiple strings:
Results:
- Ignore
NULLvalues:
Results:
- Using Arrays to Join Strings:
Results:
- Use in conjunction with other functions:
Results:
Notes
- When the input string or array element is
NULL, theCONCAT_WSfunction will ignore these values. - If all input strings or array elements are
NULL, an empty string is returned. - If the separator
sepis alsoNULL, a NULL is returned.
Through the above examples and explanations, you can better understand the usage and functionality of the CONCAT_WS function. In practical applications, you can flexibly use this function to concatenate strings or array elements as needed.
