0

I have a mySQL statement which ends in:

ON DUPLICATE KEY UPDATE ....

And then I go and update all my values in my row. My issue is in my table when I created it I have a date column with data type:

TIMESTAMP

And default entry is:

CURRENT_TIMESTAMP

My issue is that I need the timestamp to update too. Is there a way to have mySQL auto update the time stamp when I update everything else manually?

Rohit Gaikwad
  • 817
  • 2
  • 8
  • 24
Mike
  • 6,751
  • 23
  • 75
  • 132
  • possible duplicate of [MySQL ON UPDATE CURRENT\_TIMESTAMP not updating](http://stackoverflow.com/questions/5571323/mysql-on-update-current-timestamp-not-updating) – e4c5 Sep 10 '15 at 03:24
  • If you say - 'I go and update ALL my values in my row', what do you expect from MySQL? MySQL will store ALL row values from UPDATE statement. – Devart Sep 10 '15 at 05:45
  • Well I update ever column except fhe time stamp one. Which is similar to when I insert I insert into every column except the fime stamp and mySQL updates the time stamp automatically. – Mike Sep 10 '15 at 05:52
  • Can you show CREATE TABLE, UPDATE queries? – Devart Sep 10 '15 at 06:58

1 Answers1

1

You have to set on update CURRENT_TIMESTAMP for attributes in your table.

Jazi
  • 6,569
  • 13
  • 60
  • 92
  • And I don't have to set a value for it? – Mike Sep 10 '15 at 13:23
  • So I was just playing around in mySQL work bench. Where do I set the attributes? – Mike Sep 11 '15 at 01:19
  • Go to the database and select your table - > then click the structure view->click edit option for the particular filed->now you can see "Attributes" click this dropdown list and choose "on update CURRENT_TIMESTAMP" – Franklin Innocent F Sep 11 '15 at 05:28