Skip to main content

CONCAT

Concatenates its arguments into one string. NULL arguments are skipped, unlike the || operator, which returns NULL when either operand is NULL.

See also:
[SELECT] [CONCAT_WS] [ Concatenation ]


Syntax​

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

Arguments​

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

Return Value(s)​

Returns a string. If every argument is NULL, the result is an empty string.


Examples​

Skip NULL values​

The NULL argument contributes nothing to the result:

SELECT CONCAT('stackql', '-', NULL, 'labs') AS v;
|--------------|
| v |
|--------------|
| stackql-labs |
|--------------|

Build a label from columns​

The following query labels each repository in a GitHub organization with its primary language:

SELECT name, CONCAT(name, ' (', language, ')') AS label
FROM github.repos.repos
WHERE org = 'stackql-labs';

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