This is currently all that I have simply because I wanted to test adding items to a table, and making sure that said item wasn't a duplicate. I saw that if you add INSERT IGNORE that it supposedly stops the creation of duplicated items but in my case, that didn't work.
CREATE TABLE IF NOT EXISTS testing (test0 TEXT, test10 TEXT);
INSERT IGNORE INTO testing VALUES ("TEST1","TEST2");
INSERT IGNORE INTO testing VALUES ("TEST1","TEST2");
INSERT IGNORE INTO testing VALUES ("TEST1","TEST2");
INSERT IGNORE INTO testing VALUES ("TEST1","TEST2");
INSERT IGNORE INTO testing VALUES ("TEST1","TEST2");
CodePudding user response:
The purpose of INSERT IGNORE, is to not interrupt the execution of insert statements if one fails for any reason.
For example if you try to insert string value in a Integer column, it would just ignore the error and insert nothing then.
I think in your case you need to create a UNIQUE constraint for desired fields :)
CodePudding user response:
INSERT IGNORE just works in case of avoiding errors when you do the insert statement, it simply gonna let you insert the values because as I see there is not an identifier or PRIMARY KEY or UNIQUE CONSTRAINT to identify each element as unique that key is the one who cannot be duplicate, the "test01" and "test10" are just normal data types.
