PostgreSQL CONCATENATE(||) Operator

CONCATENATE(||) Operator

The PostgreSQL concatenate operator ( || ) is used to concatenate two or more strings and non strings.


string1 || string2 or sting || non-string or non-string || string

PostgreSQL Version: 9.3



SELECT 'w'||3||'resource' AS "Concatenate Operator ( || )"; 

Sample Output:

 Concatenate Operator ( || )
(1 row)

PostgreSQL CONCATENATE OPERATOR ( | | ) using Column Name

Sample Table: employees

If we want to display the first name, last name and concatenate of the first name and last name of that employee who belongs to the dept 15 from the employees table, the following SQL can be executed:


SELECT first_name,last_name,
first_name||' '||last_name AS "Name of Employee"
FROM employees WHERE department_id=20;

Sample Output:

 first_name | last_name | Name of Employee
 Michael    | Hartstein | Michael Hartstein
 Pat        | Fay       | Pat Fay
(2 rows)

Previous: System Information Functions
Next: PostgreSQL String Functions Introduction

Follow us on Facebook and Twitter for latest update.