• Resolved tubella

    (@tubella)


    What is an SQL query to replace HTML in posts when there are 2 variables?

    Example:

    All website posts have many paragraphs like this:

    <h5>
    PARAGRAPH TEXT GOES HERE
    </h5>

    I need to replace

    <h5>

    with

    and

    </h5>

    with

    Queries

    UPDATE wp_posts SET post_content = REPLACE (post_content, ‘

    <h5>’, ‘

    ‘);

    UPDATE wp_posts SET post_content = REPLACE (post_content, ‘</h5>

    ‘, ‘

    ‘);

    don’t help.

    IMPORTANT:
    I cannot run separate queries, i.e. one for

    and then for <h5>.
    I need to somehow replace

    <h5> in one set.

    Thank you.

Viewing 1 replies (of 1 total)
  • Is it because you have <h5> instead of </h5>?
    Can you find some pattern to distinguish between the beginning <h5> and the ending <h5>?
    Even if you use a regular expression, it would clump them together unless you can tell the difference between the start and the end <h5>.

    I suggest you use the plugin Search Regex instead of doing MySQL queries, since it has the option to show you what would be changed before changing it. If you don’t know regular expressions, you might need to read up on that first.
    And if you do have a way to distinguish between start and end <h5>, you can use a two step approach.

Viewing 1 replies (of 1 total)
  • The topic ‘SQL Post Info Replace’ is closed to new replies.