Hi everyone! I am new here and I have one simple question.
I have table article tags with two fiels: page_id | tag
For each tag new row is inserted. So the same pageId can be in more rows (for each tag new row) and also each tag can be in more than one row (for each pageId another row).
But how can I avoid duplicates? Let's say user inserts 10 tags in one step.
INSERT IGNORE INTO tags (page_id, tag) VALUES (1,'tagname'),(1,'anothertag'),...
won't work because page_id and tag can not be unique as the same page_id can be used for another tag.
Do I actually need to make for 10 tags 20 queries? For each one first
$rows...SELECT COUNT(*) WHERE page_id=1 AND tag='tagname'
Is this the way or how?