skip to Main Content

How to replace one string to another one in mysql including language setting ?
Example query for arabic language ( "ar" ) unfortunately it doesnt work 🙁

UPDATE 
`wp_posts` 
SET `post_contant` = REPLACE(`post_content`,'str1','str2') 
FROM wp_posts 
WHERE post_status = 'publish' 
AND ID IN (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(description, '"ar";i:', -1), ';',1) FROM wp_term_taxonomy WHERE taxonomy = 'post_translations');

2

Answers


  1. Chosen as BEST ANSWER

    I have noticed that that query returns results not only numbers. So I need only ID numbers. How to remove all values which not are numbers ?

    This is part of query used for ID IN () to get all ID numbers:

    SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(description, '"ar";i:', -1), ';',1) FROM wp_term_taxonomy WHERE taxonomy = 'post_translations'


  2. You have a small error in your codee, the first from clause is no valid

    UPDATE `wp_posts` 
    SET 
        `post_contant` = REPLACE(`post_content`, 'str1', 'str2')
    WHERE
        post_status = 'publish'
            AND ID IN (SELECT 
                SUBSTRING_INDEX(SUBSTRING_INDEX(description, '"ar";i:', - 1),
                            ';',
                            1)
            FROM
                wp_term_taxonomy
            WHERE
                taxonomy = 'post_translations');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search