MYSQL中replace into的用法

今天介绍一下mysql中replace into的用法,是insert into的增强版。 通常我们在向表中插入数据时,我们经常会遇到这样的情况:1、首先判断数据是否存在;2、如果不存在,则插入;3、如果存在,则更新。 那么 MySQL 中如何实现这样的逻辑呢?答案就使用: replace into replace into t(id, update_time) values(1, now()); ……