Reputation: 3638
I want to update all the empty logout_time fields into 2011-12-26 14:48:36.
I tried the following query so as to update the logout_time field (timestamp) in the log_details table:
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time =''
It doesn't work. Please help me to fix it.
Upvotes: 4
Views: 14576
Reputation: 6718
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time IS NULL
Upvotes: 1
Reputation: 1828
Check if those "empty" fields are '0000-00-00 00:00:00'. If it's timestamp most likely that would be the case and not "empty" as null empty. The best way is to check what exactly you have in fields you want to update.
//update
if field is actually NULL then it should be
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time IS NULL
Upvotes: 1
Reputation: 23282
update log_details set logout_time='2011-12-26 14:48:36',tab_status='0'
where logout_time ='0000-00-00 00:00:00'
this query should help because the timestamp column empty means '0000-00-00 00:00:00'
Upvotes: 1
Reputation: 72636
Try with UNIX_TIMESTAMP function in this way :
update log_details set logout_time=UNIX_TIMESTAMP('2011-12-26 14:48:36'),tab_status='0'
where logout_time =''
Upvotes: 1