Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    6

    Unanswered: Removing categories in Wordpress via phpmyadmin

    Sorry to bother you with a remedial sounding question - I'm currently trying to remove categories and posts from those categories from a Wordpress database.

    I'm using phpmyadmin to run queries, as Wordpress support suggested running the following:

    Code:
    DELETE * FROM wp_post2cat WHERE category_id=2;
    DELETE FROM wp_posts USING wp_posts p1 LEFT JOIN wp_post2cat p2 ON p1.ID = p2.post_id
    WHERE p2.post_id IS NULL;
    However, it doesn't seem to work, and MySQL help seems to suggest the syntax is wrong.

    I'd really appreciate if someone could advise - if possible - on how to correct the query statement, so that I can remove Category ID=23 and all posts associated with that category via editing of the database.

    Hopefully it's similar to the above, but I'm not competent enough to know how to do this.

    Many thanks for your time.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i think the first query is the one that's giving the trouble (you said "doesn't seem to work" which means i gotta guess) because mysql does not expect the asterisk after DELETE

    the second one should work, or you could do it like this --
    Code:
    DELETE wp_posts
      FROM wp_posts 
    LEFT 
      JOIN wp_post2cat 
        ON wp_post2cat.post_id = wp_posts.ID 
     WHERE wp_post2cat.post_id IS NULL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by SimonDevise View Post
    Hi . Why you don't remove that category and all posts from your admin panel ?
    probably because he solved his problem six years ago
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •