MySQL Forums
Forum List  »  Newbie

Re: How to Replace a word
Posted by: Keith Larson
Date: July 03, 2013 07:22PM

This works but you have to take advantage of the period at the end.

CREATE TABLE `forumpost` (
`name` varchar(255) DEFAULT NULL
) ENGINE=InnoDB
mysql> select name from forumpost;
+----------------------------+
| name |
+----------------------------+
| An auditor drives an audi. |
| An auditor drives a volvo. |
+----------------------------+

UPDATE forumpost SET name = REPLACE(name, 'audi.', 'toyota.') WHERE name LIKE '%audi.';
Query OK, 1 row affected (0.20 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from forumpost;
+------------------------------+
| name |
+------------------------------+
| An auditor drives an toyota. |
| An auditor drives a volvo. |
+------------------------------+


Otherwise you need to look into options by using SUBSTRING and LOCATE

Just trying to help....

http://anothermysqldba.blogspot.com

Options: ReplyQuote


Subject
Written By
Posted
July 01, 2013 10:26PM
Re: How to Replace a word
July 03, 2013 07:22PM
July 03, 2013 11:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.