#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    How delete post older than x?


    Hi guys,
    How delete post older than x and shorter than y? It is in Wordpres MySQL database. Ive tried:
    SELECT *
    FROM `wp_posts`
    WHERE `post_type` = 'post'
    AND DATEDIFF( NOW( ) , `post_date` ) >350
    AND LENGTH( `post_content` ) <50

    so SELECT is for selecting, I use than DELETE...

    but it is not working. Whats is wrong? Thanks a lot. Peter

    PS: I am newbie...sorry
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    how could we tell you why it's "not working" (whatever that means) when we don't even have your query?

    Post your actual DELETE query. What happens when you execute it? Do you get a syntax error? Does it simply not delete the rows it should delete?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    ok - so it is so


    I have large database with posts of Wordpress. I mean over 500 000 rows. And I would like to DELETE rows, in where are posts shorter than 50 characters and older than 60 days. (both contitions have to be realize together).

    The CODE is only my experiment, how it do....Thanks Peter
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Originally Posted by sikec
    The CODE is only my experiment, how it do....
    So? Just post the DELETE query, then we can fix the errors.

    I'm not sure what you expect from us. I mean, when you already have a query, what's the problem with using it? What you've written down above looks pretty good. But you should use CHAR_LENGTH() instead of LENGTH() to account for multibyte encodings.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by Jacques1
    So? Just post the DELETE query, then we can fix the errors.

    I'm not sure what you expect from us. I mean, when you already have a query, what's the problem with using it? What you've written down above looks pretty good. But you should use CHAR_LENGTH() instead of LENGTH() to account for multibyte encodings.
    I expect the CODE which is functional. My CODE is wrong - it is finding only two rows...but in database are thaousands of these posts, than are short than 50 and older than 60 days....
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    You do realize that the above query requires the posts to be older than 350 days?

    But since you obviously don't want to work on your own query and instead expect us to write you a new one, you'll have to wait for our query service. I won't do that.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by Jacques1
    You do realize that the above query requires the posts to be older than 350 days?

    But since you obviously don't want to work on your own query and instead expect us to write you a new one, you'll have to wait for our query service. I won't do that.
    60 was second experiment...ok, thank you, but reason is not on the world, it is perhaps too hard...I see...
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Well, it seems it's too hard for you to copy and paste a fricking query into this forum.

    I asked you again and again to show your query, but you keep wasting our time with "experiments" that "don't work". What's the point of that? Give us your actual, real query. Then we can tell you what's wrong. Enough with the "experiments".

    Anyway, I'm not interested in this kind of game. Bye.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by Jacques1
    Well, it seems it's too hard for you to copy and paste a fricking query into this forum.

    I asked you again and again to show your query, but you keep wasting our time with "experiments" that "don't work". What's the point of that? Give us your actual, real query. Then we can tell you what's wrong. Enough with the "experiments".

    Anyway, I'm not interested in this kind of game. Bye.
    I must apologize..it is my fault...you have true, it is only in CHARL_LENGHT...thank you Jacques1 for help! Peter

IMN logo majestic logo threadwatch logo seochat tools logo