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(bareNULLfails inference—useNULL(VARCHAR)or build anARRAY[...]and useCONCAT_WS_FN) NULLentries in the list are omitted (same idea asCONCAT); useCOALESCEwhen 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 VARCHAR | f2 VARCHAR |
|---|---|
| A-B-C | Apple, Banana |
Edge cases
FeatureQL
SELECT
f1 := CONCAT_WS('-', 'A', NULL(VARCHAR), 'B') -- NULL piece omitted; no extra delimiter gap
;Result
| f1 VARCHAR |
|---|
| A-B |