How to ‘insert if not exists’ in MySQL?
see http://bogdan.org.ua/2007/10/18/mysql-insert-if-not-exists-syntax.html
there’s also INSERT … ON DUPLICATE KEY UPDATE
syntax, you can find explanations on dev.mysql.com
Post from bogdan.org.ua
18th October 2007
To start: as of the latest MySQL, syntax presented in the title is not possible. But there are several very easy ways to accomplish what is expected using existing functionality.
There are 3 possible solutions: using INSERT IGNORE, REPLACE, or INSERT … ON DUPLICATE KEY UPDATE.Imagine we have a table:
CREATE TABLE `transcripts` (
1858 views