Example
Insert ignore indicates that if the same record already exists, the current new data is ignored;
Insert ignore into table (name) select name from table2
Example
Insert into inserts data if any. If the primary key is not inserted
1. Multiple groups of values can be inserted in an insert statement at a time. Each group of values is enclosed by a pair of parentheses and separated by commas, as shown below:
Insert into 'News' (title, body, time) values ('www. bKjia. c0m', 'body 1', now (), ('title 2', 'body 2', now ());
The following code describes the differences between them:
Create table testtb (
Id int not null primary key,
Name varchar (50 ),
Age int
);
Insert into testtb (id, name, age) values (1, "www.111Cn.net", 13 );
Select * from testtb;
Insert ignore into testtb (id, name, age) values (1, "aa", 13 );
Select * from testtb; // It is still 1, "bb", 13. Because id is the primary key, the primary key is repeated, but ignore is used, the error is ignored.
Replace into testtb (id, name, age) values (1, "aa", 12 );
Select * from testtb; // The data is changed to 1, "aa", 12
For more details, see http://www.bKjia. c0m/database/mysql/56643.htm