Connecting Tech Pros Worldwide Forums | Help | Site Map

Using REPLACE to replace multiple values in query result

Newbie
 
Join Date: Oct 2007
Posts: 23
#1: Oct 21 '07
Hi,

I'm running a query that displays a list of values. for example the result will be :

a
b
c
d


I would like to replace "a","b" and "c" with strings of my own. How is that possible ? Using the "Replace" function allowed me to change only one string.

Thanks.

iburyak's Avatar
Expert
 
Join Date: Nov 2006
Posts: 1,017
#2: Oct 21 '07

re: Using REPLACE to replace multiple values in query result


You can use case or nested replace.

Expand|Select|Wrap|Line Numbers
  1. select case when col in (a,b,c) then 'string here' else col end

or
Expand|Select|Wrap|Line Numbers
  1. select replace(replace(col, 'a', 'string here'), 'b', 'string here') ......

Good Luck.
Reply