WordPress.org

Ready to get started?Download WordPress

Forums

Manipulating Categories with phpMyAdmin (2 posts)

  1. 040310b
    Member
    Posted 4 months ago #

    1. I tried, by querying phpMyAdmin, to delete older posts in particular categories.

    The following "seemed" to successfully show posts in one particular category(1772) that are over 400 days old:

    SELECT *
    FROM wp_posts a
    LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
    LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
    LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
    LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
    WHERE e.term_id =1772
    AND DATEDIFF(NOW(), <code>post_date</code>) > 400

    However, the following query, apparently, failed to delete the aforementioned posts:

    delete a,b,c,d
    FROM wp_posts a
    LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
    LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
    LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
    LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
    WHERE e.term_id =1772
    AND DATEDIFF(NOW(), <code>post_date</code>) > 400

    What did I do wrong, above?

    2. Separately, I tried the following phpMyAdmin query to merge my category 7 into my category 112731:

    UPDATEwp_term_relationships`
    SET term_taxonomy_id = 7
    WHERE term_taxonomy_id = 112731;`

    That also failed, apparently. What did I do wrong there?

  2. 040310b
    Member
    Posted 4 months ago #

    The "delete query" I was attempting in 1, above, worked, but, apparently, the entire category was deleted, instead of just tweets older than 400 days.

    What did I do wrong?

    delete a,b,c,d
    FROM wp_posts a
    LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
    LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
    LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
    LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
    WHERE e.term_id =1772
    AND DATEDIFF(NOW(), <code>post_date</code>) > 400

    Separately, I tried the following phpMyAdmin query to merge my category 7 into my category 112731. Is the query correct, for that purpose?:

    UPDATE wp_term_relationships
    SET term_taxonomy_id = 112747
    WHERE term_taxonomy_id = 112748;

Reply

You must log in to post.

About this Topic