Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Force UPDATE of MySQL Record When Nothing Is Changing

Tags:

mysql

onupdate

My database table has a column defined to use ON UPDATE CURRENT_TIMESTAMP:

  • Field: last_access
  • Type: timestamp
  • Collation:
  • Attributes: on update CURRENT_TIMESTAMP
  • Null: No
  • Default: CURRENT_TIMESTAMP
  • Extra: ON UPDATE CURRENT_TIMESTAMP

How can I force this last_access field to update for a given record when no other data in the record is changing?

like image 569
Jim Fell Avatar asked Feb 09 '12 21:02

Jim Fell


1 Answers

UPDATE your_table SET last_access = CURRENT_TIMESTAMP(); ?

like image 70
berty Avatar answered Oct 08 '22 15:10

berty