Function Reference

CONCAT

Concatenates the text representations of all arguments into one string.

PostgreSQL 17.5
CONCAT(value[, ...])

Parameters

value
Value of any type, converted to text

Return value

A string (text); NULL arguments are skipped, so the result is never NULL

Examples

Joining two strings

PostgreSQL 17.5
SELECT CONCAT('Post', 'greSQL');
concat
PostgreSQL

NULL and a number among the arguments

PostgreSQL 17.5
SELECT CONCAT('Post', NULL, 'greSQL', 17);
concat
PostgreSQL17

Name and status from a table

PostgreSQL 17.5
SELECT CONCAT(member_name, ' (', status, ')') AS member
FROM FamilyMembers;
member
Headley Quincey (father)
Flavia Quincey (mother)
Andie Quincey (son)
Lela Quincey (daughter)
Annie Quincey (daughter)
Ernest Forrest (father)
Constance Forrest (mother)
Wednesday Addams (daughter)

Details

The || operator also joins strings, but gives NULL with NULL: 'a' || NULL returns NULL, while CONCAT('a', NULL) returns a.

See also

Where to learn