数据库表中有个字段: latest_receive_time, 类型是timestamp,因业务需求,需要在这个时间的值上作一次加法运算,加59秒,并且有一定的where条件限制。
执行语句如下:
select id,latest_receive_time,second(latest_receive_time),date_add(latest_receive_time, interval 59 second) from t_order where latest_receive_time is not null and second(latest_receive_time) = 0;
这个查询语句的意思就是取出latest_receive_time字段值不是null且秒是0秒的记录!
条件确定后,要更新那也容易了,即:
update t_order set latest_receive_time=date_add(latest_receive_time, interval 59 second) where latest_receive_time is not null and second(latest_receive_time) = 0;