Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 REPLACE LIKE '%_word_%'

Author  Topic 

SQLapprentice
Starting Member

29 Posts

Posted - 2012-02-15 : 02:29:56
Hi all,

I want to replace a word in a text column with another word. However that word can be found in text as being part of other strings, like "xxxxxwordxxxx".

My problem is I just want to replace the standalone word.

For that I tried to replace all the other strings which include 'word' for them not to be replaced in the main replacement:

sql> UPDATE versao SET texto=REPLACE(text,'word','*#*') WHERE texto LIKE '%_word_%';

But this command replaces every words that have a match with 'word' include the word I want to replace.

How can I make MySQL interpret 'word' different from 'xxxwordxxx'?

Thanks in advance






visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-15 : 09:13:20
Did you try like?
sql> UPDATE versao SET texto=REPLACE(text,'word','*#*') WHERE texto LIKE '% word %';



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -