Posted By

jturmel on 09/22/09


Tagged

mysql insert update timestamp trigger


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

j4kp07
farondomenicgmailcom
benvds


MySQL Trigger


 / Published in: SQL
 

  1. CREATE TRIGGER table_created BEFORE INSERT ON `table`
  2. FOR EACH ROW SET NEW.created = NOW(), NEW.created = '0000-00-00 00:00:00';
  3.  
  4. CREATE TRIGGER table_updated BEFORE UPDATE ON `table`
  5. FOR EACH ROW SET NEW.updated = NOW(), NEW.created = OLD.created;

Report this snippet  

You need to login to post a comment.