On this page

    Categories: String


    Concatenate with separator. Returns a string resulting from the joining of two or more string values in an end-to-end manner. Uses the first argument as the separator between each string.


    CONCAT_WS(separator, expression1, expression2, [ … expressionN ]) → string

    • separator (optional): An expression of any character type, such as binary or varchar. However, all arguments must be the same data type.
    • expression: An expression can be any data type. All arguments must be the same data type.


    CONCAT_WS example
    SELECT CONCAT_WS('-', 'cat', 'dog', 'bird')
    -- cat-dog-bird

    Usage Notes

    This function does not append a separator if there is only one argument. If the separator is NULL, then the result is NULL. If any of the expressions are NULL, they are ignored. If only the separator is provided, or all provided expressions are NULL, then an empty string is returned.