• Resolved JaneLitte

    (@janelitte)


    I am not sure if anyone here can help me, but I want to do a search and replace in my database. There is a word that is used in certain post titles that I want removed.

    This is the query I have devised, but I am not getting the end of the query correct:

    UPDATEwp_postsSET post_title = replace( post_title, 'REVIEW:', '' ) FROMwp_termsWHEREterm_id=9 LIMIT 0

    I want to search the database for all posts with the term (formerly category) = 9.

Viewing 2 replies - 1 through 2 (of 2 total)
  • This should do:

    UPDATE wp_posts AS p
    INNER JOIN wp_term_relationships AS tr ON p.ID=tr.object_id
    INNER JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id=tt.term_taxonomy_id
    SET post_title = replace( post_title, 'REVIEW:', '' ) WHERE tt.term_id=9;

    Make a back up of your database first. Always a good idea before manually modifying it.

    Thread Starter JaneLitte

    (@janelitte)

    Thank you very much. This worked perfect.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘MySQL WordPress Database query help needed’ is closed to new replies.