سؤال

I want to find duplicate data with this query which may occur during insertion. Is there any way to find it?

INSERT INTO table_tags (tag) VALUES ('tag_a'),('tab_b'),('tag_c')
ON DUPLICATE KEY UPDATE tag=tag;
هل كانت مفيدة؟

المحلول

Try something like this

INSERT INTO table_tags
   (tag)
VALUES
   (?)
ON DUPLICATE KEY UPDATE
   tag     = VALUES('tag_a')

Note that, column tag should be unique

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top