语法:insert into employee (id,name,age,desc)
values(1,'xiaoming',18,'first'),(2,'xiaohong',19,'second')
ON DUPLICATE KEY UPDATE
name = VALUES(name),
age = VALUES(age),
desc = VALUES(desc);
根据唯一键,如果唯一键有的话,就更新后面指定的列,否则就insert;
语法:insert into employee (id,name,age,desc)
values(1,'xiaoming',18,'first'),(2,'xiaohong',19,'second')
ON DUPLICATE KEY UPDATE
name = VALUES(name),
age = VALUES(age),
desc = VALUES(desc);
根据唯一键,如果唯一键有的话,就更新后面指定的列,否则就insert;