Oracle: Concatenation Operator

Concatenation Operator in oracle is used to Concatenate two strings values. The concatenation in oracle can be done using the CONCAT() keyword. Also, concatenation can be done by using the '||' symbol.

Syntax

CONCAT( string1, string2);

Example

we have a Stu table as shown below:

Concat()

1. CONCAT TWO COLUMNS

Now, we want concat Name and Subject column together. Follow the code for the same:

select CONCAT(name,Subject)from Stu;

Output


Concat()

2. CONCAT MORE THAN TWO COLUMNS

We, want to contact Name, Subject, and Section Columns. Follow the code for the same:

select CONCAT(CONCAT(name,Subject),Section)from Stu;

OR

select name||Subject||Section from Stu;

NOTE: We cannot Concat 3 columns altogether. Therefore, we use the nest concat method to concatenate more than 2 columns.

Output 1


Concat()

Output 2

Concat()