Title: SQL Statement to delete both posts and postmeta based on post_parent
Last modified: August 21, 2016

---

# SQL Statement to delete both posts and postmeta based on post_parent

 *  [Lithgowers](https://wordpress.org/support/users/lithgowers/)
 * (@lithgowers)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/sql-statement-to-delete-both-posts-and-postmeta-based-on-post_parent/)
 * I have a catalog of items that are posts with postmeta attached to them. I am
   looking to delete all posts with a specific post_parent value and the associated
   postmeta.
 * Using phpMyAdmin I want to execute an SQL query that will accomplish this. I 
   thought this would work but it doesn’t:
 * DELETE FROM `wp_posts`, `wp_postmeta` WHERE post_parent = 261 AND post_id = id;
 * There is an obvious syntax error but I am unsure where or more specifically why.
 * #1064 – You have an error in your SQL syntax; check the manual that corresponds
   to your MySQL server version for the right syntax to use near ‘WHERE post_parent
   = 261 AND post_id = id’ at line 1
 * Any help is greatly appreciated.

The topic ‘SQL Statement to delete both posts and postmeta based on post_parent’
is closed to new replies.

## Tags

 * [delete posts](https://wordpress.org/support/topic-tag/delete-posts/)
 * [sql-query](https://wordpress.org/support/topic-tag/sql-query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Lithgowers](https://wordpress.org/support/users/lithgowers/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/sql-statement-to-delete-both-posts-and-postmeta-based-on-post_parent/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
