I've got a table by having an auto_corporation id (primary key). I'm attempting to steer clear of the insertion of duplicate rows.
Illustration of a replica row:
id | field a | field b | field c | 1 4 6 7 2 4 6 7
The important thing (id) isn't duplicate as it is instantly produced by mySQL, but other area are the same.
You need to use ON DUPLICATE KEY UPDATE and proclaiming the fields as unique .
Should you specify ON DUPLICATE KEY UPDATE, along with a row is placed that would result in a duplicate value inside a UNIQUE index or PRIMARY KEY, an UPDATE from the old row is carried out.
Create a unique index on fields a,b,c.
ALTER TABLE `table` ADD UNIQUE ( `a` , `b` , `c` );
Result in the three rows composite key.