0

i knew how to replace a single value all over the field by using REPLACE method like

   UPDATE `table` SET `field` = REPLACE(`field`, `string`, `anothervalue`)

but what if i have to replace different values by different other things in the same field e.g "," is to replace by "." and "/" is to replace by white space " " and "hons" is to replace by "honours" in the same field, can i do it in a single query?

2 Answers 2

2

You can cascade the replace

UPDATE `table` 
SET `field` = replace(replace(replace(`field`, ',', '.'), '/', ' '), 'hons', 'honours')
Sign up to request clarification or add additional context in comments.

Comments

2
UPDATE `table` 
SET `field` = REPLACE(REPLACE(REPLACE(`field`,'/',' ') ',','.') , 'hons', 'honours')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.