mysql> describe break;
+-------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| start | datetime | YES | | NULL | |
| end | datetime | YES | | NULL | |
| duration | datetime | YES | | NULL | |
| date | datetime | YES | | NULL | |
| employee_id | int(11) | NO | MUL | NULL | |
+-------------+----------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
我想使用上表中的开始值和结束值计算(并更新)“持续时间”列。例如:
UPDATE break SET duration=TIMEDIFF(start, end) WHERE employee_id=1;
唉,这将持续时间列设置为 0000-00-00 00:00:00
mysql> select * from break\G;
*************************** 1. row ***************************
id: 30
start: 2013-08-06 15:43:17
end: 2013-08-06 15:55:42
duration: 0000-00-00 00:00:00
date: 2013-08-06 15:43:17
employee_id: 1
1 row in set (0.00 sec)
帮助