UPDATE without changing the date of a record

Asked

Viewed 320 times

2

How do I change a record in my table and keep the date the record was created.

In the INSERT I’m using the method now(). When I wear one UPDATE to change only one column the date is being changed, and I need to keep the date the record was created, tested first on phpMyAdmin and then on my application, in both ways the date is being changed.

  • How is the UPDATE and how the column is defined?

  • "UPDATE requests SET status='$status' WHERE id = '$id'"; The date column is of type: timestamp. In my case I need to update only the column "status".

  • And which column is being updated together and should keep the creation date, as mentioned?

  • The "date" column was being updated and changing the record creation date and I just wanted to change the "status", but it was already solved with the @William Novak tip.

1 answer

3

Your table must have a column with the attribute:

ON UPDATE CURRENT_TIMESTAMP

Remove the attribute from the column and any update in your table will not change the date/time in the column.

  • 2

    Whoa, it worked, man, thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.