PostgreSQL - CONCAT Function

Last Updated : 1 Aug, 2026

PostgreSQL CONCAT() function combines two or more strings into a single string. It is commonly used to merge text values, such as names, addresses, or other character data, into one output.

  • Combines multiple strings into a single string.
  • Supports creating formatted text by joining character values.

Syntax

SELECT CONCAT(string1, string2, ...);

Where:

  • string1, string2, ...: The strings or column values to be concatenated.

Examples

Consider the following Employees table for the examples below:

Screenshot-2026-07-27-150950
Employees Table

Example 1: Concatenate First Name and Last Name

Query:

SELECT CONCAT(FirstName, ' ', LastName) AS FullName
FROM Employees;

Output:

Screenshot-2026-07-27-151107
  • The CONCAT() function combines the FirstName and LastName columns into a single string.

Example 2: Concatenate Multiple Columns

Query:

SELECT CONCAT(FirstName, ' ', LastName, ' - ', Department) AS EmployeeDetails
FROM Employees;

Output:

Screenshot-2026-07-27-151138
  • The CONCAT() function combines multiple strings and column values into a formatted output.

Example 3: Using CONCAT() with NULL

CREATE TABLE Contacts (
ContactID INT,
Name VARCHAR(50),
Email VARCHAR(100),
Phone VARCHAR(20)
);

INSERT INTO Contacts VALUES
(1, 'John Smith', 'john@example.com', '555-1234'),
(2, 'Emily Johnson', 'emily@example.com', NULL),
(3, 'Michael Brown', 'michael@example.com', '555-6789');

Query:

SELECT CONCAT(Name, ' (', Email, ') ', Phone) AS ContactInfo
FROM Contacts;

Output:

Screenshot-2026-07-27-151247
  • The CONCAT() function ignores NULL values, so rows with NULL in the Phone column are concatenated without returning NULL.
Comment

Explore