Skip to content

Instantly share code, notes, and snippets.

@MnO2
Created May 5, 2011 06:53
Show Gist options
  • Save MnO2/956653 to your computer and use it in GitHub Desktop.
Save MnO2/956653 to your computer and use it in GitHub Desktop.
SQLite Tricks
-- insert a record if it doesn't exist, ignore if it does exist
-- if EventTypeName column is unique
INSERT OR IGNORE INTO EVENTTYPE (EventTypeName) VALUES 'ANI Received'
-- otherwise
INSERT INTO EVENTTYPE (EventTypeName)
SELECT 'ANI Received'
WHERE NOT EXISTS (SELECT 1 FROM EVENTTYPE WHERE EventTypeName = 'ANI Received');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment