title: INSERT IF NOT EXISTS with NULL value
body: <p>I have two tables: tags and linking table photos_tags. I want to add a new tag, so I check if the tag is already in the tags table and if not I insert one. My tables look something like this: tags(id, name), photos_tags(photos_id, tags_id). Now I tried to do this with:</p>
  
  <pre><code>IF NOT EXISTS (SELECT * FROM tags WHERE name=*tagsName*)  
    INSERT INTO tags VALUES (NULL, *tagsName*); --NULL used for autonumbering
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>INSERT INTO tags (  
    SELECT NULL, *tagsName*  
    WHERE NOT EXISTS (  
      SELECT * FROM tags  
      WHERE name=*tagsName*  
    )  
  );
  </code></pre>
  
  <p>Both statements result in syntax errors:  </p>
  
  <ul>
  <li>in the first statement near <code>if</code></li>
  <li>in the second statement near <code>select</code></li>
  </ul>
  
  <p>What should my query look like?</p>