Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Wie verwende ich ON DUPLICATE KEY UPDATE in MySQL ohne einen UNIQUE-Index oder PRIMARY KEY?

INSERT INTO `table` (value1, value2) 
SELECT 'stuff for value1', 'stuff for value2' FROM `table` 
WHERE NOT EXISTS (SELECT * FROM `table` 
                  WHERE value1='stuff for value1' AND value2='stuff for value2') 
LIMIT 1

Quelle:How to 'insert if notexists ' in MySQL?