开发者

Updated Timestamp field in MySQL through PHP

I have a database table in mysql with a 开发者_运维问答field that is of "TIMESTAMP" type. I need help writing the SQL query to update the field with the current timestamp.

UPDATE tb_Test set dt_modified = ?????


Use:

UPDATE tb_Test 
   SET dt_modified = CURRENT_TIMESTAMP
 WHERE ? -- if you don't specify, ALL dt_modified values will be updated

You can use NOW() instead of CURRENT_TIMESTAMP, but CURRENT_TIMESTAMP is ANSI standard so the query can be ported to other databases.


ALTER TABLE tb_Test MODIFY COLUMN dt_modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

Now whenever any field is changed the dt_modified will be updated by the special trigger.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜