I need to replace the special characters å,ä,ö (with a or o) in my WP database for all image attachments. How can I apply this search and replace only to affect these links?
Edit: Solved
I need to replace the special characters å,ä,ö (with a or o) in my WP database for all image attachments. How can I apply this search and replace only to affect these links?
Edit: Solved
Solved -
UPDATE wp_postmeta SET meta_value = REPLACE(REPLACE(REPLACE(meta_value, 'å', 'a') , 'ä', 'a') , 'ö', 'o')
WHERE LOWER(RIGHT(meta_value, 5)) = '.jpeg'
OR LOWER(RIGHT(meta_value, 4)) IN ('.jpg', '.gif', '.png')
Just do this with your string:
$yourString = preg_replace ( '/å/' , 'a' , $yourString )
$yourString = preg_replace ( '/ä/' , 'a' , $yourString )
$yourString = preg_replace ( '/ö/' , 'o' , $yourString )
If you just want to do it with an SQL sentence, then you can try this :
REPLACE(REPLACE(REPLACE(StringColumn, 'å', 'a') , 'ä', 'a') , 'ö', 'o')
And you can use it in a SELECT, UPDATE, ... sentences, like this:
UPDATE MyTable
SET StringColumn = REPLACE(REPLACE(REPLACE(StringColumn, 'å', 'a') , 'ä', 'a') , 'ö', 'o')