Afficher un message
Vieux 05/09/2007, 02h44   #4
Gary Josack
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Editing fields in bulk

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=lists@byoteki.com
>

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)

  Réponse avec citation
 
Page generated in 0,07441 seconds with 9 queries