我想更新所有空的logout_time字段到2011-12-26 14:48:36。如何更新mysql表的时间戳字段?
我尝试下面的查询,以便在log_details表更新logout_time场(时间戳):
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time =''
它不工作。请帮我解决它。
我想更新所有空的logout_time字段到2011-12-26 14:48:36。如何更新mysql表的时间戳字段?
我尝试下面的查询,以便在log_details表更新logout_time场(时间戳):
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time =''
它不工作。请帮我解决它。
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time IS NULL
检查这些“空”字段是否为'0000-00-00 00:00:00'。如果时间戳最可能是这种情况,而不是空的,因为空为空。最好的方法是检查你想要更新的领域究竟有什么。
//更新
如果字段实际上是NULL,那么它应该是
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time IS NULL
时间戳字段实际上是空的。我想用quey填充手动值。请告诉我,我该怎么做?有什么办法可以做到吗? –
尝试用'IS NULL'我编辑了我的答案 – Kokers
与UNIX_TIMESTAMP功能试试这样:
update log_details set logout_time=UNIX_TIMESTAMP('2011-12-26 14:48:36'),tab_status='0'
where logout_time =''
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time ='0000-00-00 00:00:00'
此查询应该帮助,因为时间戳列空表示'0000-00-00 00:00:00'
表格架构是? – piotrekkr
当您尝试运行此命令时,获得的确切错误是什么?你把这个;在最后(我问,因为它不在你在这里输入的查询中,并且总是打破这些事情) – Drahkar
log_details是表名,logout_time是表中存储用户注销时间的时间戳字段。由于一些错误的价值没有添加,因为我的预期,所以我必须改变时间戳值,无论它是空的2011-12-26 14:48:36手动。 –