List:General Discussion« Previous MessageNext Message »
From:Gary Josack Date:September 5 2007 1:44am
Subject:Re: Editing fields in bulk
View as plain text  
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?
>
> --MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
mysql> select * from replacetest;
+----+--------------------------------+
| id | reptest                        |
+----+--------------------------------+
|  1 | this is a test US-Complete wii |
|  2 | look US-Complete is here       |
|  3 | Fun test                       |
+----+--------------------------------+
3 rows in set (0.00 sec)

mysql> update replacetest set reptest=replace(reptest, 'US-Complete', 
'US Complete') where reptest like '%US-Complete%';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> select * from replacetest;
+----+--------------------------------+
| id | reptest                        |
+----+--------------------------------+
|  1 | this is a test US Complete wii |
|  2 | look US Complete is here       |
|  3 | Fun test                       |
+----+--------------------------------+
3 rows in set (0.00 sec)

Thread
Editing fields in bulkBrian Dunning5 Sep
  • RE: Editing fields in bulkHartleigh Burton5 Sep
  • Re: Editing fields in bulkGary Josack5 Sep
  • Re: Editing fields in bulkBaron Schwartz5 Sep
  • Re: Editing fields in bulkMartijn Tonies5 Sep