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

# PostgreSQL CONCAT_WS() Function

**Summary**: in this tutorial, you will learn how to use the PostgreSQL `CONCAT_WS()` function to concatenate strings into a single string, separated by a specified separator.

## Introduction to PostgreSQL CONCAT_WS() function

The PostgreSQL `CONCAT_WS()` function allows you to concatenate multiple strings into a single string separated by a specified separator.

Here's the basic syntax of the `CONCAT_WS` function:

```sql
CONCAT_WS(separator, string1, string2, string3, ...)
```

In this syntax:

- `separator`: Specify the separator that you want to separate the strings. The `separator` should not be `NULL`.
- `string1`, `string2`, `string3`, ..: These are strings that you want to concatenate. If any string is NULL, it is ignored by the function.

The `CONCAT_WS` returns a single string that combines the `string1`, `string2`, `string3`… separated by the separator.

If the separator is `NULL`, the `CONCAT_WS` will return `NULL`.

In practice, you typically use the `CONCAT_WS` function to combine values from different columns with a custom separator.

## PostgreSQL CONCAT_WS() function examples

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

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

The following example uses the `CONCAT_WS()` function to concatenate two strings with a space:

```sql
SELECT CONCAT_WS(' ', 'PostgreSQL', 'Tutorial') title;
```

Output:

```text
        title
---------------------
 PostgreSQL Tutorial
(1 row)
```

In this example, we use the `CONCAT_WS()` function to concatenate the strings `'PostgreSQL'` and `'Tutorial'` with a space separator. The result string is `'PostgreSQL Tutorial'`.

### 2) Using the CONCAT_WS() function with the table data

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

![customer table](https://neon.com/postgresqltutorial/customer.png)The following example uses the `CONCAT_WS()` to concatenate values from the `first_name` and `last_name` columns of the `customer` table using a space as a separator:

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

Output:

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

The query returns a result set with a single column `full_name` containing the full names of all customers.

## Summary

- Use the `CONCAT_WS` function to concatenate multiple strings into a single string separated by a specified separator.
- The `CONCAT_WS` function skips `NULL` values.

---

## 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](https://neon.com/postgresql/postgresql-string-functions/postgresql-concat-function)
- [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)
