Using REPLACE to replace multiple values in query result

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yoavyoavyoav
    New Member
    • Oct 2007
    • 23

    Using REPLACE to replace multiple values in query result

    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
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    You can use case or nested replace.

    Code:
    select case when col in (a,b,c) then 'string here' else col end

    or
    Code:
    select replace(replace(col, 'a', 'string here'), 'b', 'string here') ......

    Good Luck.

    Comment

    • Samrat Gavale
      New Member
      • Apr 2011
      • 1

      #3
      @ iburyak,
      very helpful post.
      Thank you so much!

      Comment

      Working...