WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] SQL query to delete postmeta (3 posts)

  1. magicpadx
    Member
    Posted 2 years ago #

    hi,

    i used this SQL command to select at the unused postmeta

    but i want to delete them, and could'nt figure out how

    SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL LIMIT 30;

  2. s_ha_dum
    Member
    Posted 2 years ago #

    I think this is right.

    DELETE pm
    FROM wp_postmeta pm
    LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
    WHERE wp.ID IS NULL;

    This code comes with no warranty or promise of fitness for any purpose whatsoever. Test it on a development server with dummy data or may god have mercy on your soul.

  3. magicpadx
    Member
    Posted 2 years ago #

    perfect,

    thx man

Topic Closed

This topic has been closed to new replies.

About this Topic