0

I have this column

column
London/paris
toronto/paris
Tokyo/paris

I want to update only the word 'paris'

My desirable result:

column
London/turkey
toronto/turkey
Tokyo/turkey

Can I have a condition like if next to paris is toronto I update it to berlin?

EDIT.
I want to know the queries in oracle or sybase. (I am not sure if I can ask this question separated in ora and syb, I hope a moderator give me an advice about that)

Cœur
  • 37,241
  • 25
  • 195
  • 267
Moudiz
  • 7,211
  • 22
  • 78
  • 156

2 Answers2

2

you can use the replace function for TSQL to do this

UPDATE myTable
SET MyColumn = REPLACE(MyColumn, 'paris', 'turkey')
WHERE MyColumn LIKE '%paris%'
Hip Hip Array
  • 4,665
  • 11
  • 49
  • 80
0

Use:

update #t set col1 = str_replace(col1, 'paris', 'turkey')
Ben
  • 51,770
  • 36
  • 127
  • 149
deepak
  • 141
  • 2
  • 9
  • This is almost identical to the earlier answer, but less efficient as you're going to update everything whether it needs it or not. – Ben Jul 27 '13 at 11:16