Prevent auto increment on MySQL duplicate insert
You could modify your INSERT to be something like this: INSERT INTO tablename (tag) SELECT $tag FROM tablename WHERE NOT EXISTS( SELECT tag FROM tablename WHERE tag = $tag ) LIMIT 1 Where $tag is the tag (properly quoted or as a placeholder of course) that you want to add if it isn’t already there. … Read more