OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Editing fields in bulk

From: Baron Schwartz (baronxaprb.com)
Date: Tue Sep 04 2007 - 20:30:28 CDT


Brian Dunning wrote:
> I have a column where I need to replace all instances of the text
> "US-Complete" (contained within a long sentence) with "US Complete".
> There are probably 50 or 100 of them. I'm really scared to do it since I
> can't risk screwing up that column - what's the correct syntax?

UPDATE tbl SET col=REPLACE(col, 'US-Complete', 'US Complete');

If there are spaces in front and back, perhaps you should add some extra
insurance to avoid changing 'US-Completely' or 'BUS-Complete' as well:

UPDATE tbl SET col=REPLACE(col, ' US-Complete ', ' US Complete ');

The best insurance is to do a SELECT first to see what will be changed:

SELECT col, REPLACE(col, 'US-Complete', 'US Complete') FROM tbl;

Baron

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql