84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
如题 比如 a表是这样的
name number time 哈哈 23 2015-04-02 17:32:08 嘻嘻 44 呵呵 56 2015-04-16 17:32:08
用sql 语句要达到的效果是修改name字段的同时将time字段更新到当前时间 求大神指教
人生最曼妙的风景,竟是内心的淡定与从容!
update a set name="123", time=now()
Or directly set the time field to automatically update
You can use trigger. Set the trigger for the name field update event. create trigger update_time after update on a for each row set new.time=now();
time field type is set to timestamp current_timestamp
timestamp current_timestamp
Another method is to use ON UPDATE CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
If the database does not provide this function, you can use trigger as @drla said
update a set name="123", time=now()
Or directly set the time field to automatically update
You can use trigger. Set the trigger for the name field update event.
create trigger update_time after update on a for each row set new.time=now();
time field type is set to
timestamp current_timestamp
Another method is to use
in this field when creating the tableON UPDATE CURRENT_TIMESTAMP
If the database does not provide this function, you can use trigger as @drla said