How to replace all instances of a particular value in a mysql database with another?
- by Joseph
I'm looking for a MySQL equivalent of what str_replace is for PHP. I want to replace all instances of one word with another, I want to run a query that will replace all "apples" with "oranges".
The reason why:
UPDATE fruits SET name='oranges' WHERE name='apples';
isn't going to work for my situation, is because I often times have multiple words in a table row separated by commas like: "apples, pears, pineapples". In this case I want just apples to be replaced by oranges and pear and pineapples to stay in tact.
Is there any way to do this?