> This page location: String Functions > CONCAT
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL CONCAT() Function

**Summary**: in this tutorial, you will learn how to use the PostgreSQL `CONCAT()` function to concatenate two or more strings into one.

## Introduction to PostgreSQL CONCAT() function

To concatenate two or more strings into a single string, you can use the string concatenation operator || as shown in the following example:

```sql
SELECT
   'John' || ' ' || 'Doe' AS full_name;
```

Output:

```text
 full_name
-----------
 John Doe
(1 row)

```

The following statement uses the concatenation operator (`||`) to concatenate a string with `NULL`:

```sql
SELECT
   'John' || NULL result;
```

It returns `NULL`.

```text
 result
--------
 null
(1 row)

```

Since version 9.1, PostgreSQL has introduced a built-in string function called `CONCAT()` to concatenate two or more strings into one.

Here's the basic syntax of the `CONCAT()` function:

```sql
CONCAT(string1, string2, ...)
```

The `CONCAT` function accepts a list of input strings, which can be any string type including `CHAR`, `VARCHAR`, and `TEXT`.

The `CONCAT()` function returns a new string that results from concatenating the input strings.

Unlike the concatenation operator `||`, the `CONCAT` function ignores `NULL` arguments.

To concatenate two or more strings into one using a specified separator, you can use the [CONCAT_WS()](https://neon.com/postgresql/postgresql-string-functions/postgresql-concat_ws) function.

## PostgreSQL CONCAT() function examples

Let's take some examples of using the PostgreSQL `CONCAT()` function.

### 1) Basic PostgreSQL CONCAT() function example

The following example uses the `CONCAT()` function to concatenate three literal strings into one:

```sql
SELECT
  CONCAT ('John', ' ', 'Doe') full_name;
```

Output:

```text
 full_name
-----------
 John Doe
(1 row)
```

### 2) Using the CONCAT() function with table data example

We'll use the `customer` table from the [sample database](https://neon.com/postgresql/postgresql-getting-started/postgresql-sample-database):

![customer table](https://neon.com/postgresqltutorial/customer.png)The following statement uses the `CONCAT()` function to concatenate values in the `first_name`, a space, and values in the `last_name` columns of the `customer` table into a single string:

```sql
SELECT
  CONCAT (first_name, ' ', last_name) AS full_name
FROM
  customer
ORDER BY
  full_name;
```

Output:

```text
       full_name
-----------------------
 Aaron Selby
 Adam Gooch
 Adrian Clary
 Agnes Bishop
 Alan Kahn
...
```

### 3) Using the CONCAT() function with NULL

First, [create a table](../postgresql-tutorial/postgresql-create-table) called `contacts` and [insert some rows](../postgresql-tutorial/postgresql-insert-multiple-rows) into it:

```sql
CREATE TABLE contacts (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL,
    phone VARCHAR(15)
);

INSERT INTO contacts (name, email, phone)
VALUES
    ('John Doe', 'john.doe@example.com', '123-456-7890'),
    ('Jane Smith', 'jane.smith@example.com', NULL),
    ('Bob Johnson', 'bob.johnson@example.com', '555-1234'),
    ('Alice Brown', 'alice.brown@example.com', NULL),
    ('Charlie Davis', 'charlie.davis@example.com', '987-654-3210')
RETURNING *;
```

Output:

```text
 id |     name      |        email        |    phone
----+---------------+---------------------+--------------
  1 | John Doe      | john.doe@example.com      | 123-456-7890
  2 | Jane Smith    | jane.smith@example.com    | null
  3 | Bob Johnson   | bob.johnson@example.com     | 555-1234
  4 | Alice Brown   | alice.brown@example.com   | null
  5 | Charlie Davis | charlie.davis@example.com | 987-654-3210
(5 rows)


INSERT 0 5
```

Second, use the `CONCAT()` function to concatenate the values in the `name`, `email`, and `phone` columns of the `contacts` table:

```sql
SELECT
  CONCAT(name, ' ', '(', email, ')', ' ', phone) contact
FROM
  contacts;
```

Output:

```
                     contact
--------------------------------------------------
 John Doe (john.doe@example.com) 123-456-7890
 Jane Smith (jane.smith@example.com)
 Bob Johnson (bob.johnson@example.com) 555-1234
 Alice Brown (alice.brown@example.com)
 Charlie Davis (charlie.davis@example.com) 987-654-3210
(5 rows)
```

The output indicates that the `CONCAT()` function ignores `NULL`.

## Summary

- Use the PostgreSQL `CONCAT()` function to concatenate two or more strings into one.

---

## Related docs (String Functions)

- [ASCII](https://neon.com/postgresql/postgresql-string-functions/postgresql-ascii)
- [CHR](https://neon.com/postgresql/postgresql-string-functions/postgresql-chr)
- [CONCAT_WS](https://neon.com/postgresql/postgresql-string-functions/postgresql-concat_ws)
- [FORMAT](https://neon.com/postgresql/postgresql-string-functions/postgresql-format)
- [INITCAP](https://neon.com/postgresql/postgresql-string-functions/postgresql-initcap)
- [LEFT](https://neon.com/postgresql/postgresql-string-functions/postgresql-left)
- [LENGTH](https://neon.com/postgresql/postgresql-string-functions/postgresql-length-function)
- [LOWER](https://neon.com/postgresql/postgresql-string-functions/postgresql-lower)
- [LPAD](https://neon.com/postgresql/postgresql-string-functions/postgresql-lpad)
- [LTRIM](https://neon.com/postgresql/postgresql-string-functions/postgresql-ltrim)
- [MD5](https://neon.com/postgresql/postgresql-string-functions/postgresql-md5)
- [POSITION](https://neon.com/postgresql/postgresql-string-functions/postgresql-position)
- [REGEXP_MATCHES](https://neon.com/postgresql/postgresql-string-functions/postgresql-regexp_matches)
- [REGEXP_REPLACE](https://neon.com/postgresql/postgresql-string-functions/regexp_replace)
- [REPEAT](https://neon.com/postgresql/postgresql-string-functions/postgresql-repeat)
- [REVERSE](https://neon.com/postgresql/postgresql-string-functions/postgresql-reverse)
- [REPLACE](https://neon.com/postgresql/postgresql-string-functions/postgresql-replace)
- [RIGHT](https://neon.com/postgresql/postgresql-string-functions/postgresql-right)
- [RPAD](https://neon.com/postgresql/postgresql-string-functions/postgresql-rpad)
- [RTRIM](https://neon.com/postgresql/postgresql-string-functions/postgresql-rtrim)
- [SPLIT_PART](https://neon.com/postgresql/postgresql-string-functions/postgresql-split_part)
- [SUBSTRING](https://neon.com/postgresql/postgresql-string-functions/postgresql-substring)
- [TO_CHAR](https://neon.com/postgresql/postgresql-string-functions/postgresql-to_char)
- [TO_NUMBER](https://neon.com/postgresql/postgresql-string-functions/postgresql-to_number)
- [TRANSLATE](https://neon.com/postgresql/postgresql-string-functions/postgresql-translate)
- [TRIM](https://neon.com/postgresql/postgresql-string-functions/postgresql-trim-function)
- [UPPER](https://neon.com/postgresql/postgresql-string-functions/postgresql-upper)
