Insert ignore into

Hi,

I’m trying to use INSERT IGNORE INTO but even if I specify duplicates in every field, it insert it anyway.

For example if I run this twice, I’ll have two rows:

INSERT IGNORE INTO kt_results (Turn_ID, Kingdom_ID, Officer_ID, Action, Chance, Result, Target) VALUES (10, 125, 126, ‘Construction (Structures)’, ‘for 100 gold’, ‘93.75’, ‘Hanzhong /// Ministry of Merit’)

Is it because I don’t have a unique or primary key?

Yes. INSERT IGNORE says to ignore the insert if a data integrity violation is made by the INSERT (i.e. duplicate primary key).
If you have no unique and/or primary a data integrity violation will never be made and the row will always be inserted, regardless whether a row with the same data already exists.

Yes. Think carefully before you create one, i.e., which fields should part of the key. I can’t see that from here :slight_smile:

Thank you, so is my best course of action unique / primary field then?