I am making some big changes to my database, so I need to replace a lot of text with some new text, but only when a certain word exist.
Table
*-----------------------------------------------*
| id | name | adress | town |
*-----------------------------------------------*
I have a table like this. I want to replace “adress” and “town” in every row of the table, where “town = new york” (for example).
So every time the text “new york” occurs in “town”, both adress and town should be replaced with something else. Only one time- when i run the script.
Can anyone help me with this? I imagine i could use preg match and replace function from PHP in some way do to this, or can it be done purely with a SQL command?
Thank you guys
Or,
WHERE UPPER(town) like UPPER('%new york%')to be case insensitive.