Skip to main content

CONCAT_WS

Functions › Text › Change a string

Joins its arguments into one string with a separator between them. NULL arguments are skipped, with no separator for them.

Syntax​

CONCAT_WS( <separator>, <value> [, <value> ...] )

Arguments​

ArgumentDescription
<separator>The text to put between the values.
<value>One or more values to join. A number, boolean or date is joined as its text.

Returns​

Text. NULL when <separator> is NULL. NULL values are left out, so CONCAT_WS(', ', 'a', NULL, 'b') is a, b. Empty when every value is NULL.

Usage notes​

  • On large tables the engine runs it in the data store, unless an argument is a decimal number or a timestamp.

Examples​

SELECT a.key, CONCAT_WS(', ', a.street, a.city, a.country) AS address FROM tables.crm.account a
keyaddress
A-121 George St, Sydney, AU
A-19Auckland, NZ

See also​

CONCAT · SPLIT_PART · STRING_AGG