PostgreSQL CONCATENATE(||) Operator
CONCATENATE(||) Operator
The PostgreSQL concatenate operator ( || ) is used to concatenate two or more strings and non strings.
Syntax:
string1 || string2 or sting || non-string or non-string || string
PostgreSQL Version: 9.3
Example:
Code:
SELECT 'w'||3||'resource' AS "Concatenate Operator ( || )";
Sample Output:
Concatenate Operator ( || ) ----------------------------- w3resource (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:
Code:
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
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook