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 can use this also.
INSERT INTO `tableName` ( `field1`, `field2`,`field3`) SELECT `field1`, `field2`,`field3` FROM `tableName` WHERE NOT EXISTS (SELECT 1 FROM `tableName` WHERE `field1` = 'value' AND `field2` = 'value' AND `field3` = 'value' );