title: MySQL query help for Tag database
body: <p>I'm looking to set up a tag system using this normalised table structure:</p>
  
  <pre><code>Table: Item
  Columns: ItemID, Title, Content
  
  Table: Tag
  Columns: TagID, Tag_Name
  
  Table: ItemTag
  Columns: ItemID, TagID
  </code></pre>
  
  <p>Where the Item table is my general info table, what i want to do is have an additional  single text field in my form, and ask users to insert their tags, seperated by a comma. Nothing out of the ordinary and seen all over the web.</p>
  
  <p>What i need help with is the query which takes those comma seperated inputs and:</p>
  
  <ol>
  <li>Checks they don't already exist in the Tag table</li>
  <li>Adds them if they don't exist (where tag_id is a self-incremental field anyway)</li>
  <li>Links inputted tag id's (whether new or existing) with the ItemID from my general info table.</li>
  </ol>
  
  <p>Can someone help me with the loop for each comma-separated value please?</p>
  
  <p>Thanks
  Dan</p>