Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PostgreSQL – CONCAT_WS Function

  • Last Updated : 08 Oct, 2021

In PostgreSQL, the CONCAT_WS function is used to concatenate strings with a separator. Like the CONCAT function, the CONCAT_WS function is also variadic and ignored NULL values.

The following illustrates the syntax of the CONCAT_WS function.

Syntax: CONCAT_WS(separator, string_1, string_2, ...);

Let’s analyze the above syntax:

  • The separator is a string that is used to separate the resultant strings.
  • The string_1, string_2, are strings that is to be converted.
  • The CONCAT_WS function returns a combined string that is the combination of string_1, string_2, etc., separated by the separator.

Example 1:

The following statement concatenates the symbols (ie, ^,+,-,/):

SELECT CONCAT_WS ('^^^', '+++ ', '---', '///');


Example 2:

The below statement uses the CONCAT_WS function to concatenate three strings into one:

 CONCAT_WS ('***', 'geeks ', 'for', 'geeks');


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!