Skip to content

Instantly share code, notes, and snippets.

@dongilbert
Created May 3, 2012 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dongilbert/2587304 to your computer and use it in GitHub Desktop.
Save dongilbert/2587304 to your computer and use it in GitHub Desktop.
This SQL will delete postmeta that's still around from deleted posts.
-- Old Post Meta sometimes creeps
-- in from manually deleting revisions
-- and other things direct from the
-- database. Using this SQL below
-- you can remove the postmeta remnants
-- that have been left behind.
DELETE a
FROM wp_postmeta AS a
LEFT JOIN wp_posts AS b
ON b.ID = a.post_id
WHERE b.ID IS NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment