Solved

Oracle SQL query - Concatenate text to specific field value issue

Posted on 2014-11-09
2
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

627 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