CONCAT()
Joins two or more strings together into a single string.
Description
CONCAT joins two or more strings end to end into one combined string. It's
commonly used to build full names, labels, or formatted messages out of
separate columns.
Syntax
CONCAT(string1, string2, ...)Parameters
| Name | Description | Optional |
|---|---|---|
| string1, string2, ... | Any number of text values, columns, or literal strings to concatenate, joined in the order given. | No (at least one argument is required) |
Return Type
CONCAT returns a VARCHAR (text) value.
Examples
Employees & Departments
Loading database engine...
Employees & Departments
Loading database engine...
CONCAT vs the || operator
Many databases, including DuckDB, also support || for concatenation, so
first_name || ' ' || last_name produces the same result as
CONCAT(first_name, ' ', last_name). CONCAT is often preferred because
it reads more clearly with many arguments.
Common Mistakes
- Forgetting the separator.
CONCAT(first_name, last_name)producesAliceJohnsonwith no space; you need an explicit' 'argument in between. - Concatenating a NULL value. In some databases
CONCATtreats NULL as an empty string, while in others any NULL argument makes the whole result NULL. Wrapping a nullable column inCOALESCEfirst avoids surprises. - Trying to concatenate non-text columns directly. Numbers usually get
auto-converted, but it's safer to
CASTthem to text explicitly if the database is strict about types.
Related Functions
See also: UPPER, LOWER, SUBSTRING.