문제

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