Results 1 to 4 of 4

Thread: SQL Help?

  1. #1
    Join Date
    Oct 2003
    Location
    Tas, Australia
    Posts
    2,488

    SQL Help?

    This is probably easy, but I can't figure it out, so help will really be appreciated.

    I am trying to set all empty last_comment_time field in my table to the same value as image_date (another field). What SQL query do I use?

    This didn't work:

    Code:
    update set last_comment_time = image_date where last_comment_time=0
    Thank you all
    New site: www.talkutas.com

  2. #2
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    Code:
    update `table` set `last_comment_time` = image_date where `last_comment_time` = 0;
    I think you need to set the table name. Also, `image_date` will not work unless you do a join. (assuming you copy/pasted the code)

  3. #3
    Join Date
    Oct 2003
    Location
    Tas, Australia
    Posts
    2,488
    Ooops.

    How should I join it then?
    New site: www.talkutas.com

  4. #4
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    I'd do two separate queries.

    Code:
    $query1 = mysql_select_assoc(mysql_query(QUERY));
    Code:
    $query2 = mysql_query('update `table` set `last_comment_time` = "'.$query1['image_date'].'" where `last_comment_time` = 0;');

Posting Permissions

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