Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2011
    Posts
    1

    Unanswered: Simple Update Query

    Hello Everyone,

    I'm a bit of a newbie with SQL but know enough to really break things. I would like to write some SQL which I can simply paste into phpMyAdmin or add to a PHP script, to update all the 'post_date' to today on my recruitment website. Thus making all my jobs look new again.

    Each record has a unique ID although as I add jobs, more records will exist (obviously).

    I've looked on a few forums but can't find a straight forward answer. What I'm basically looking for is a magical script to select all the records in the jobs table and update all the 'post_date' to today (2011-09-15 15:00:01).

    thanks in advance.
    Ren

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    UPDATE jobs
       SET post_date = CURRENT_TIMESTAMP
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2011
    Posts
    1
    You can check this,
    update xxxx set post_date=date_format(now(),'%Y-%m-%d %H:%i:%s');

    Regards,
    niab

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    no, niab, the DATE_FORMAT function is completely unnecessary

    and NOW() is mysql's proprietary non-standard equivalent for CURRENT TIMESTAMP

    so the answer is already given, in post # 2

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Tags for this Thread

Posting Permissions

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