-> account VARCHAR(10),
-> `time` DATETIME
->)
Query OK, 0 rows affected (0.08 sec)
mysql>
mysql>INSERT INTO time_account
-> SELECT 'a' , '2000-01-01 00:00:00' UNION ALL
-> SELECT 'b' , '2011-01-01 00:00:00'
Query OK, 2 rows affected (0.02 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql>
mysql>SELECT * FROM time_account
+---------+---------------------+
| account | time|
+---------+---------------------+
| a | 2000-01-01 00:00:00 |
| b | 2011-01-01 00:00:00 |
+---------+---------------------+
2 rows in set (0.00 sec)
mysql>UPDATE
-> time_account
->SET
-> `time` = ADDTIME(`time`, '50:00:00')
->WHERE
-> account IN ('a','b')
Query OK, 2 rows affected (0.05 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql>SELECT * FROM time_account
+---------+---------------------+
| account | time|
+---------+---------------------+
| a | 2000-01-03 02:00:00 |
| b | 2011-01-03 02:00:00 |
+---------+---------------------+
2 rows in set (0.00 sec)
看看mysql文档里面关于timestamp的说明会清楚一些这块是容易弄错,建表的第一列timestamp属性的字段如果不显示给默认值,都会自动更新.
http://dev.mysql.com/doc/refman/5.1/zh/column-types.html#datetime
11.3.1.1.
自MySQL
4.1以来的TIMESTAMP属性
我觉得一般用date就够用了
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)