CONCAT_WS
CONCAT_WS
stands for concatenation with separator.
The first argument is a separator that is placed in between the remaining arguments when concatenating them together. If any of the expressions is NULL it is skipped in the concatenated output.
Syntax
CONCAT_WS(separator, expression, [ expression, [expression ...]])
Arguments
separator: A separator expression. This may be a column name, the result of another function, or a math operation.
expression: any set of expressions. This may be a column name, the result of another function, or a math operation.
Return Type
The concatenated string.
Examples
SELECT CONCAT_WS('a','1','2','3'); **** +----------------------------+ | CONCAT_WS('a','1','2','3') | +----------------------------+ | 1a2a3 | +----------------------------+
SELECT CONCAT_WS('a','1',NULL,'3'); **** +-----------------------------+ | CONCAT_WS('a','1',NULL,'3') | +-----------------------------+ | 1a3 | +-----------------------------+