Open In App

PostgreSQL – CONCAT_WS Function

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:

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:

Article Tags :