title: Postgresql insert if not exists
body: <p>I'm very new to SQL, and all I get is error after error, so any help would be appreciated.</p>
  
  <p>I have a tags table: id, name, slug</p>
  
  <p>I've Google'd, searched on Stackoverflow, but nothing works for me. I'm trying to create a tag if it doesn't exist, but always return the ID whether it's created or exists.</p>
  
  <pre><code>INSERT INTO tags (name, slug)
  SELECT ('Wow', 'wow')
  WHERE NOT EXISTS (SELECT id FROM tags WHERE slug = 'wow')
  RETURNING id;
  </code></pre>
  
  <p>Here's what I have: <a href="http://sqlfiddle.com/#!15/4050a/18" rel="noreferrer">http://sqlfiddle.com/#!15/4050a/18</a></p>