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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.