
Question:
i have a table 'tag_article_assoc' with [tagId,articleId] fields. i want to insert new tags for a specific article (lets say articleId=23) but skip records already in db. i am not sure on the right syntax, any ideas?
INSERT INTO wd_article_tag_assoc (tagId,articleId) VALUES ('$upTag','23') ON DUPLICATE KEY UPDATE...
thanks S
Solution:1
I suppose you have the tagId,articleId both as primary key in your database
INSERT INTO wd_article_tag_assoc (tagId,articleId) VALUES ('$upTag','23') ON DUPLICATE KEY UPDATE tagId=$upTag
You are welcome to read "INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE"
Solution:2
INSERT IGNORE INTO wd_article_tag_assoc (tagId,articleId) VALUES ('$upTag','23')
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon