Help!! I Need help in edit MySQL query!!

Discussion in 'MySQL' started by ivychai75, Jul 21, 2008.

  1. #1
    Hi there,

    I'm working with wordpress and mysql database and I try to change the post
    date on table wp_posts and column "post_date". Currently all my date is on
    "2008-07-14 09:46:42" .

    I want to run the sql query so it may change the
    date later one day than each other like record 1 = 2008-07-14 09:46:42 ,
    record 2 = 2008-07-15 09:46:42 , record 3 = 2008-07-16 09:46:42 and so
    on...I've over 2000 posts right now and is impossible to change it manually.

    anyone can help me what query should i use to change all this? also, I want
    to change column "post_status" from "publish" to "future" , how can I do this
    in sql query? I'm using phpmyadmin in my cpanel, and it have the ability to
    insert query and all that.


    Extremely appreciate your help here, and thanks in advanced!
     
    ivychai75, Jul 21, 2008 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #2
    So your basic problem is that you want to publish the posts automatically in future? And thats why you want to tun those SQL queries?

    Just have a look at the right-bar of posting page where there is a small calendar. Set your publishing date in that!
     
    rohan_shenoy, Jul 21, 2008 IP
  3. ivychai75

    ivychai75 Banned

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi rohan,

    Thanks for your reply. Not in future post, but I want to change my current database...
     
    ivychai75, Jul 21, 2008 IP
  4. spyrit

    spyrit Well-Known Member

    Messages:
    1,788
    Likes Received:
    94
    Best Answers:
    0
    Trophy Points:
    150
    #4
    i did this one, just go to your admin pannel to the post you want to change the date to and click edit and there you can change the date.
     
    spyrit, Jul 22, 2008 IP
  5. blueroomhosting

    blueroomhosting Peon

    Messages:
    13
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try this:

    set @i=0; update wp_posts set post_date = date_add('2008-07-14 09:46:42', interval @i:=@i+1 day), post_status='future';

    Sets up a variable i, and increments i for each row, adding that number of days to the original date and putting the result into the post_date field. (I don't know whether there's a better way of accessing the row number of the result set...)

    Please back up your database before you run this!

    cheers
    Helen
     
    blueroomhosting, Jul 22, 2008 IP
  6. ivychai75

    ivychai75 Banned

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks blueroom,

    i got it solve now
     
    ivychai75, Jul 22, 2008 IP