Jump to content

[SOLVED] Find & Replace


Topshed

Recommended Posts

I am very new to mySQL and I have been trying to find the right syntax for Finding  an occurance of a string

and replacing it with another, but everything I try in phpmyadmin on my hosting company fails with errors

 

I am wondering if different versions of mySQL have different syntax

 

My Hosting Company is using MySQL 3.23

 

On my machine I have 5.1

 

I need to be able to change Multiple errors on the fly either by direct input or with a

small php program where I can fill in the blanks

 

This is my latest attempt

 

UPDATE table
SET column = REPLACE(`class2`, "Bullied", "Bulleid")
WHERE column LIKE "%Bullied%"

 

Can anyone Help please

 

Thanks

Roy...

Link to comment
https://forums.phpfreaks.com/topic/79706-solved-find-replace/
Share on other sites

The value you want to change "from" should be the second argument and the third is what you want to change it to. Also, the search should be looking for the wrong spelled word and not the correct one. So, I would imagine that you meant to have it like this:

 

UPDATE table_name

   SET column_name = REPLACE(column_name, "Bulleid", "Bullied")

   WHERE column_name LIKE "%Bulleid%"

;

 

Manual page showing REPLACE():

http://dev.mysql.com/doc/refman/4.1/en/string-functions.html#function_replace

 

Link to comment
https://forums.phpfreaks.com/topic/79706-solved-find-replace/#findComment-403729
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.