WordPress.org

Ready to get started?Download WordPress

Forums

Duplicates of scheduled posts SQL (2 posts)

  1. mercinary123
    Member
    Posted 1 year ago #

    Instead of using plugins I want to use an SQL cron to complete this task.

    I want to delete duplicates out of the database but I want it to compare scheduled or "future" wp_post.post_status to "published" posts. If it's a future post I want it to be deleted and leave the published post alone.

    This is what I was using which is slightly modified but it does not just limit to "future" or scheduled posts.

    SELECT bad_rows. *
    FROM wp_posts AS bad_rows
    INNER JOIN (

    SELECT post_title, post_status, post_content, MIN( id ) AS min_id
    FROM wp_posts WHERE post_status = "future"
    GROUP BY post_title, post_content
    HAVING count( * ) >1) AS good_rows ON good_rows.post_title = bad_rows.post_title
    AND good_rows.post_content = bad_rows.post_content
    AND good_rows.min_id <> bad_rows.id

  2. mercinary123
    Member
    Posted 1 year ago #

    Instead of "SELECT" I was using DELETE. I was using SELECT to test the output.

Topic Closed

This topic has been closed to new replies.

About this Topic