CONCAT_WS(...)

All functions > STRING > CONCAT_WS(...)

Returns a concatenated string from a list of strings with a separator between each element.

Syntax

CONCAT_WS(separator, string, string, …)  ·  CONCAT_WS_FN(separator, ARRAY[…])

Notes

  • Separator is inserted only between non-omitted pieces; skipped NULLs do not add an extra separator
  • An empty argument list (after bundling) yields an empty string—no leading or trailing separator
  • Variadic form: every string argument must be VARCHAR (bare NULL fails inference—use NULL(VARCHAR) or build an ARRAY[...] and use CONCAT_WS_FN)
  • NULL entries in the list are omitted (same idea as CONCAT); use COALESCE when you need empty segments with separators

Related Functions

Examples

CONCAT_WS(...)

FeatureQL
SELECT
    f1 := CONCAT_WS('-', 'A', 'B', 'C'), -- Dash between pieces
    f2 := CONCAT_WS(', ', 'Apple', 'Banana') -- Comma and space
;
Result
f1 VARCHARf2 VARCHAR
A-B-CApple, Banana

Edge cases

FeatureQL
SELECT
    f1 := CONCAT_WS('-', 'A', NULL(VARCHAR), 'B') -- NULL piece omitted; no extra delimiter gap
;
Result
f1 VARCHAR
A-B

Last update at: 2026/05/26 17:22:09