title: Update MYSQL with IF statement?
body: <p>I want to update my MYSQL table, but with a condition.</p>
  
  <p>I have a status field and a time field. If status=day, don't update time field with the current time. if status=night, update time field with current time.</p>
  
  <p>Right now, I am doing a SELECT statement, then an if statement on the returned value in PHP and then performing the UPDATE and changing all fields except the time unless status=night. Is it possible to do this all in one command?</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>Sorry, just to clarify:</p>
  
  <p>A WHERE command will only update the row if status=night. I always want all the fields within the row to be updated, but only update the time field if status=night. If status=day, update the entire row except for the time field.</p>
  
  <hr>
  
  <p>Code:</p>
  
  <pre><code>if($status=="night") {
      $query = "UPDATE post SET name="$name", comment="$comment", status="$status", time="{now()}" WHERE id='$id'";
  } else {
      $query = "UPDATE post SET name="$name", comment="$comment", status="$status" WHERE id='$id'"
  }
  </code></pre>