I have a table with an auto_inc id (primary key). I am trying to avoid the insertion of duplicate rows.
auto_inc
Example of a duplicate row:
id
You should use ON DUPLICATE KEY UPDATE and declaring the fields as unique .
If you specify ON DUPLICATE KEY UPDATE, and a row is inserted that would cause a duplicate value in a UNIQUE index or PRIMARY KEY, an UPDATE of the old row is performed.