Solved

Oracle SQL query - Concatenate text to specific field value issue

Posted on 2014-11-09
2
349 Views
Last Modified: 2014-11-09
Hi

I would like to know how i can add text to my field result when i'm runing an SQL.

Ex:
Select Case
when ID = '1' then ('TEST_' + ID)
when ID = '2' then ('NO_TEST_' + ID)
end from location;

Open in new window


So if my ID = 1 then i want to add the text "TEST_" just before the value 1.

How can i do this?

Thanks again
0
Comment
Question by:Wilder1626
2 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 total points
ID: 40431542
Here is the code:

Select Case
when ID = '1' then ('TEST_' || value)
when ID = '2' then ('NO_TEST_' || value)
else value
end from location;

Open in new window


You can test it here http://sqlfiddle.com/#!4/d6b56/4
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 40431581
Thanks for your help.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question