Bob,

Try:

UPDATE pictures set caption = REPLACE(caption,'www.bob.com',www.bubba.com')
WHERE caption like '%www.bob.com%'

Make sure you backup or copy data before trying...

See MySQL Manual 'Language Reference->String Functions'

I hope this helps...

Pat...

CocoNet Corporation
825 SE 47th Terrace
Cape Coral, FL 33904

(239) 540-2626 Voice


----- Original Message ----- 
From: "Bob Loeffler" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, November 25, 2003 6:01 PM
Subject: Replacing text using the Update command?


> Hi all!
>
> I would like to update many records in a table called "pictures" where I
> find a string in the "caption" column.  If the string (e.g. "www.bob.com")
> is found, replace it with another string (e.g. "www.bubba.com").
> Unfortunately, there is other text in the caption column of these records,
> so I can't just do a simple update.  How can I replace a string of text
> within a column without destroying the other text in that column?  For my
> example, here is a command to find all records with the text string that
I'm
> looking for:
>
> select id from pictures where caption like '%www.bob.com%';
>
> Now I want to replace the string "www.bob.com" in those records with
> "www.bubba.com". One of the records has the following in the caption
column:
>
> "There is a party at www.bob.com"
>
> Now I want it to be:
>
> "There is a party at www.bubba.com"
>
> I'm sure there is an easy way to do this.   :-)
>
> Thanks,
>
> Bob
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to