I have been racking my brain for a while now trying to sort out a problem I have been having with my mysql query and thought this would be the best place to get some help and learn how to edit my query!
So, users are able to post items which have associated tags (that are pre-defined). If you look at the link below I am trying to enter into this table the post id, with the tag that the user had selected. The correct inserts are highlighted in blue but the rest are duplicates where the query adds the same tag_id for every single existing post!
Click Here for the snapshot of the table.
The mysql query is as follows:
mysqli_query("INSERT INTO post_tag(post_id, tag_id) SELECT post_id, tag_id FROM posts INNER JOIN tag WHERE username = '$userName' AND tag IN ('$music','$sport','$tech')") or die ('Query is invalid: ' . mysql_error());;
Any help will be so appreciated! Thanks.