Skip to main content
11 events
when toggle format what by license comment
Jan 15, 2019 at 5:31 comment added Buttle Butkus @DavidSpillett you will get the same error if one of the values you're trying to INSERT ... ON DUPLICATE KEY UPDATE/REPLACE INTO is a foreign key that is not present in the parent table (column). See my answer below.
Dec 11, 2018 at 10:14 history edited David Spillett CC BY-SA 4.0
Further formatting and wording improvements.
S Dec 11, 2018 at 10:09 history suggested lloiacono CC BY-SA 4.0
improved formatting
Dec 11, 2018 at 9:12 review Suggested edits
S Dec 11, 2018 at 10:09
Mar 4, 2018 at 15:12 review Suggested edits
Mar 4, 2018 at 17:48
May 23, 2017 at 12:40 history edited CommunityBot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Jan 21, 2016 at 17:20 history edited David Spillett CC BY-SA 3.0
Added text about `ON DUPLICATE` (from comments), `MERGE` and `UPSERT`. Also spelling.
Jul 23, 2013 at 10:57 comment added David Spillett If you try INSERT a duplicate values for a primary key (or a unique index) you will always get that error. There are a couple of ways around it: check before you insert and either do an update (if something might have changed) or just don't do anything. There is also the mysql specific "ON DUPLICATE KEY UPDATE" option (see stackoverflow.com/questions/1218905/…) if you are happy to sacrifice compatibility with other RDBMSs.
Jul 22, 2013 at 19:26 vote accept Chris Burton
Jul 22, 2013 at 19:25 comment added Chris Burton Instead of grabbing all the articles from my feed, I wonder if I should just get the last article in the feed and let it INSERT or check the DB first and only INSERT what isn't there. Thoughts?
Jul 22, 2013 at 19:12 history answered David Spillett CC BY-SA 3.0