Title: SQL Post Info Replace
Last modified: February 16, 2019

---

# SQL Post Info Replace

 *  Resolved [tubella](https://wordpress.org/support/users/tubella/)
 * (@tubella)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/sql-post-info-replace/)
 * 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)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/sql-post-info-replace/#post-11213700)
 * 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.

## Tags

 * [find and replace](https://wordpress.org/support/topic-tag/find-and-replace/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Joy](https://wordpress.org/support/users/joyously/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/sql-post-info-replace/#post-11213700)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
