I'm very new to SQL, and all I get is error after error, so any help would be appreciated.
I have a tags table: id, name, slug
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.
INSERT INTO tags (name, slug)
SELECT ('Wow', 'wow')
WHERE NOT EXISTS (SELECT id FROM tags WHERE slug = 'wow')
RETURNING id;
Here's what I have: http://sqlfiddle.com/#!15/4050a/18