Mysql insert xxx on duplicate key update

创建Unique索引

CREATE UNIQUE INDEX indexname ON table(id,name,password)

之后插入数据时,如果跟索引重复,会提示无法插入数据

insert into table() values()

on duplicate key update name = values(name)

可以实现覆盖


猜你喜欢

转载自blog.csdn.net/u010113247/article/details/51181460