Skip to content
SQLSimplified
string

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

NameDescriptionOptional
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) produces AliceJohnson with no space; you need an explicit ' ' argument in between.
  • Concatenating a NULL value. In some databases CONCAT treats NULL as an empty string, while in others any NULL argument makes the whole result NULL. Wrapping a nullable column in COALESCE first avoids surprises.
  • Trying to concatenate non-text columns directly. Numbers usually get auto-converted, but it's safer to CAST them to text explicitly if the database is strict about types.

See also: UPPER, LOWER, SUBSTRING.

Search

Search lessons, functions, examples, and practice problems