Title: Database Hackery
Last modified: August 19, 2016

---

# Database Hackery

 *  Resolved [gregorsmith](https://wordpress.org/support/users/gregorsmith/)
 * (@gregorsmith)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/database-hackery/)
 * OK, how best to phrase this, I’m needing a way to select posts from a certain
   category then quickly mass replace the post excerpt using the post content.
 * I figured this would be relatively easy in MySQL and I was able to fill in blank
   excerpts using a quick:
 *     ```
       UPDATE wp_posts
       SET post_excerpt = post_content
       WHERE post_excerpt IS NULL OR post_excerpt = ''
       ```
   
 * But since the old post_category column in wp_posts isn’t being used finding a
   way to pull the post id, post_content and post_excerpt information from wp_posts,
   the object_id and term_taxonomy_id info from the wp_term_relationships tables
   and replacing the post_excerpt with the post_content if a term_taxonomy_id is
   3 is proving to be more difficult than I first imagined.
 * Can anyone think of a SQL query that might pull this off?

Viewing 1 replies (of 1 total)

 *  Thread Starter [gregorsmith](https://wordpress.org/support/users/gregorsmith/)
 * (@gregorsmith)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/database-hackery/#post-1942686)
 * Resolved, I used this query in case anyone else has this specific issue
 *     ```
       update wp_posts p
       set p.post_excerpt = p.post_content
       where p.ID in (select tr.object_id
       from wp_term_relationships tr
       where tr.object_id = p.ID
       and tr.term_taxonomy_id = 3)
       ;
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Database Hackery’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 1 participant
 * Last reply from: [gregorsmith](https://wordpress.org/support/users/gregorsmith/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/database-hackery/#post-1942686)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
