Cases
Insert Ignore indicates that if the same record already exists in, the current new data is ignored;
Insert ignore into table (name) select name from Table2
Cases
Insert into there is no data inserted, if the primary key is not inserted
A 1.insert statement can insert multiple sets of values at a time, with each set of values enclosed in a pair of parentheses, separated by commas, as follows:
INSERT INTO ' news ' (Title,body,time) 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);
The SELECT * from testtb;//is still 1, "BB", 13, because the ID is the primary key, the primary key is duplicated but the error is ignored when the ignore is used
Replace into TESTTB (id,name,age) VALUES (1, "AA", 12);
SELECT * from TESTTB; Data into 1, "AA", 12