mysql中varchar类型和datetime类型字段进行比较
我是在mysql5.7版本进行比较
表a的字段order_no和表iwebshop_tmp的字段order_no一样
需要更新iwebshop_member_order表的datetime类型expiration_time,和表b的varchar类型deadline值一样;
update iwebshop_member_order as a join iwebshop_tmp as b on a.order_no = b.order_no set a.expiration_time = b.deadline where a.expiration_time = 0;
以上是报错
以下正常:
update iwebshop_member_order as a join iwebshop_tmp as b on a.order_no = b.order_no set a.expiration_time = str_to_date(b.deadline,'%Y-%m-%d %H:%i:%s') where a.expiration_time = 0;