Oracle String concatenation allows you to append one string to the end of another string. To display the contents of two columns or more under the name of a single column, you can use the double pipe concatenation operator (||).
There are two ways to concatenate Strings in Oracle SQL . Either using CONCAT function or || operator. SELECT CONCAT( string1, string2 ) FROM dual; Since CONCAT function will only allow you to concatenate two values together.
We can concatenate a space character using the || operator. In this example, we have used the || operator to add a space character between the values Dave and Anderson. This will prevent our values from being squished together.
You have two options for concatenating strings in Oracle:
||
CONCAT example:
CONCAT(
CONCAT(
CONCAT(
CONCAT(
CONCAT('I like ', t.type_desc_column),
' cake with '),
t.icing_desc_column),
' and a '),
t.fruit_desc_column)
Using ||
example:
'I like ' || t.type_desc_column || ' cake with ' || t.icing_desc_column || ' and a ' || t.fruit_desc_column
Did you try the ||
operator ?
Concatenation Operator Documentation from Oracle >>>
select 'i like' || type_column || ' with' ect....
Below query works for me @Oracle 10G ----
select PHONE, CONTACT, (ADDR1 || '-' || ADDR2 || '-' || ADDR3) as Address
from CUSTOMER_DETAILS
where Code='341';
O/P -
1111 [email protected] 4th street-capetown-sa
The Oracle/PLSQL
CONCAT
function allows to concatenate two strings together.
CONCAT( string1, string2 )
string1
The first string to concatenate.
string2
The second string to concatenate.
E.g.
SELECT 'I like ' || type_column_name || ' cake with ' ||
icing_column_name || ' and a ' fruit_column_name || '.'
AS Cake FROM table;
Try this:
SELECT 'I like ' || type_column_name || ' cake with ' ||
icing_column_name || ' and a ' fruit_column_name || '.'
AS Cake_Column FROM your_table_name;
It should concatenate all that data as a single column entry named "Cake_Column".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With