Skip to main content

CONCAT_WS

Concatenates its arguments after the first into one string, with the first argument placed between them as a separator. NULL values are skipped, along with their separator.

See also:
[SELECT] [CONCAT] [ Concatenation ]


Syntax​

SELECT CONCAT_WS(separator, value [, value ...]) FROM <multipartIdentifier>;

Arguments​

separator
The string placed between consecutive values.

value
One or more expressions. Numbers are converted to text.

Return Value(s)​

Returns a string. The result is NULL if separator is NULL.


Examples​

Join values with a separator​

The NULL value and its separator are left out:

SELECT CONCAT_WS('-', 'a', 'b', NULL, 'c') AS v;
|-------|
| v |
|-------|
| a-b-c |
|-------|

Build a path from columns​

The following query builds an owner/repository/branch path for each repository in a GitHub organization:

SELECT CONCAT_WS('/', 'stackql-labs', name, default_branch) AS repo_path
FROM github.repos.repos
WHERE org = 'stackql-labs';

For more information, see https://www.sqlite.org/lang_corefunc.html#concat_ws