Oracle SQL Query to Combine Two Strings

Oracle SQL Query to Combine Two Strings

  • SQL
  • 1 min read

In this Oracle SQL query example, you will learn how to combine two strings.

To combine two strings in Oracle, you can use concat() function or double pipes ||operator. Below are the examples:

Using Concat Function to Combine Two Strings

The concat() function takes two arguments string1 and string2 and returns the string concatenated string1 with string2.

Syntax

concat(string1, string2)

Example

Select concat('abc', 'xyz') from dual;

Output

abcxyz

Using || Operator to Combine Two Strings

Using the || operator, you can not only combine two strings but more than two strings. Here is an example:

SELECT
    'abc'
    || 'xyz'
    || 'aaa'
    || 'bbb'
FROM
    DUAL

Output

abcxyzaaabbb