Skip to content
Related Articles

Related Articles

PostgreSQL – CONCAT_WS Function
  • Last Updated : 08 Feb, 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 seperate 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 ('^^^', '+++ ', '---', '///');

Output:

Example 2:

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

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

Output:

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :