[英]MySQL ignoring duplicates on non-primary key
I have a table created by this SQL statement: 我有一个通过此SQL语句创建的表:
CREATE TABLE employees (
id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(20),
PRIMARY KEY (id)
);
I would like to insert into the table using something like 我想使用类似的东西插入表格
INSERT IGNORE INTO employees (name) values ('foo');
but for that statement to do nothing if there is already a person with a name 'foo' in the table. 但对于该语句,如果表中已经存在一个名为“ foo”的人,则不执行任何操作。 Is there a statement out there that ignores duplicates on a field other than a primary key or a field that is defined as unique?
是否有一条语句可以忽略除主键或定义为唯一的字段以外的其他字段上的重复项?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.