Cases
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
Cases
INSERT into has no data inserted, if the primary key is not inserted
A 1.insert statement can insert multiple sets of values at a time, each set of values enclosed by a pair of parentheses, separated by commas, as follows:
INSERT INTO ' News ' values (' www.111cn.net ', ' body 1 ', now ()), (' Title 2 ', ' body 2 ', now ());
The following are the differences between code descriptions, as follows:
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;//is still 1, "BB", 13, because ID is primary key, duplicate primary key but use ignore error is ignored
Replace into TESTTB (id,name,age) VALUES (1, "AA", 12);
SELECT * from TESTTB; Data becomes 1, "AA", 12
For more detailed information, please see: http://www.111cn.net/database/mysql/56643.htm
The difference between insert IGNORE and insert INTO