From: Roy Goldhammer on 8 Jul 2010 04:33 Hello there when u run replace(Field, 'abc', 'def') it replace any text in field who have 'abc' no metter what is before and after the text But if i want to replace 'abc[', 'abc', 'abc def', 'abc def', 'abc.def' ext.... and not replace 'abcd', 'abc_def' is there a way to do this?
From: Philipp Post on 8 Jul 2010 08:49 Is that what you are looking for? UPDATE my_table SET my_column = REPLACE(my_column, 'abc', 'def') WHERE my_column IS NOT LIKE '%abcd%' AND my_column IS NOT LIKE '%abc_def%' brgds Philipp Post
From: Roy Goldhammer on 8 Jul 2010 10:49 Whell phillip It's not good because if i have on the text the same expression twice it replaces both of them. "Philipp Post" <post.philipp(a)googlemail.com> wrote in message news:ad3626d8-362f-4cbc-94dd-0a3dd1a5533c(a)x21g2000yqa.googlegroups.com... > Is that what you are looking for? > > UPDATE my_table > SET my_column = REPLACE(my_column, 'abc', 'def') > WHERE my_column IS NOT LIKE '%abcd%' > AND my_column IS NOT LIKE '%abc_def%' > > brgds > > Philipp Post
From: Vern Rabe on 8 Jul 2010 13:13 Try this: UPDATE MyTable SET MyColumn = REPLACE(REPLACE(REPLACE(MyColumn, 'abcd', 'xxxx'), 'abc', 'def'), 'xxxx', 'abcd'); If 'xxxx' might exist in the column, replace both occurrences of it in the above statement with a string that you know will never exist in the column. HTH Vern Rabe "Roy Goldhammer" wrote: > Hello there > > when u run replace(Field, 'abc', 'def') > > it replace any text in field who have 'abc' no metter what is before and > after the text > > But if i want to replace 'abc[', 'abc', 'abc def', 'abc > def', 'abc.def' ext.... > > and not replace 'abcd', 'abc_def' is there a way to do this? > > > . >
From: Vern Rabe on 8 Jul 2010 14:14
Revised solution: UPDATE MyTable SET MyColumn = REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(MyColumn, 'abc_def', '|xxxxx|'), 'abcd', '|xx|'), 'abc', 'def'), '|xx|', 'abcd'), '|xxxxx|', 'abc_def'); Vern Rabe "Vern Rabe" wrote: > Try this: > > UPDATE MyTable > SET MyColumn = REPLACE(REPLACE(REPLACE(MyColumn, 'abcd', 'xxxx'), 'abc', > 'def'), 'xxxx', 'abcd'); > > If 'xxxx' might exist in the column, replace both occurrences of it in the > above statement with a string that you know will never exist in the column. > > HTH > Vern Rabe > "Roy Goldhammer" wrote: > > > Hello there > > > > when u run replace(Field, 'abc', 'def') > > > > it replace any text in field who have 'abc' no metter what is before and > > after the text > > > > But if i want to replace 'abc[', 'abc', 'abc def', 'abc > > def', 'abc.def' ext.... > > > > and not replace 'abcd', 'abc_def' is there a way to do this? > > > > > > . > > |