From: Roy Goldhammer on
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
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
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
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
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?
> >
> >
> > .
> >