Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 1.21 KB

File metadata and controls

29 lines (20 loc) · 1.21 KB
description
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

Syntax

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

  • separator: 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.

Examples

{% code title="CONCAT_WS example" %}

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

-- cat-dog-bird

{% endcode %}

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.