June 21, 2018
Mysql: 数据存在更新,不存在插入, Insert if not exist otherwise update, mysql update or insert if not exists without primary key, replace into
一般有三种方法:
我们用名为 books 的表做演示
mysql> SELECT * FROM books LIMIT 3;
+----+-------------------------+---------------------+----------------+
| id | title | author | year_published |
+----+-------------------------+---------------------+----------------+
| 1 | In Search of Lost