With ON DUPLICATE KEY UPDATE you cannot insert another table - and there is no alternative function.
Two custom / alternative ways of doing this:
Something similar to this should work:
CREATE TABLE insert_logs ( id int not null ); delimiter | CREATE TRIGGER insert_logs_trigger BEFORE INSERT ON your_table FOR EACH ROW BEGIN INSERT INTO insert_logs SET id = NEW.id; END; |
To get a list of duplicates in a table, you can:
SELECT id FROM insert_logs HAVING COUNT(id) > 1 GROUP BY id;
newfurniturey
source share