PostgreSQL - CONCAT Function - GeeksforGeeks

PostgreSQL - CONCAT Function

Last Updated : 4 Nov, 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.

Syntax

SELECT CONCAT(string_1, string_2, ...);

Where:

  • string_1, string_2, ...: The strings or column values to be concatenated.

Examples

Consider the following Employees table for the examples below:

Screenshot-2026-10-05-165413

Example 1: Concatenate First Name and Last Name

Query:

SELECT CONCAT(first_name, ' ', last_name) AS full_name
FROM employees;

Output:

Screenshot-2026-10-05-165442
  • The CONCAT() function combines the first_name and last_name columns into a single string.

Example 2: Concatenate Multiple Columns

Query:

SELECT CONCAT(first_name, ' ', last_name, ' - ', department) AS employee_details
FROM employees;

Output:

Screenshot-2026-10-05-165536
  • The CONCAT() function combines multiple strings and column values into a formatted output.

Example 3: Using CONCAT() with NULL

CREATE TABLE contacts (
contact_id 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');

Output:

Screenshot-2026-10-05-165649

Query:

SELECT CONCAT(name, ' (', email, ') ', phone) AS contact_Info
FROM contacts;

Output:

Screenshot-2026-10-05-165730
  • The CONCAT() function ignores NULL values, so rows with NULL in the phone column are concatenated without returning NULL.
Comment

Explore