Postgres: Insert if not exist, else Ignore
pgsql: If you want to check while insertion statement whether the value exists or not, here’s an example of the syntax
INSERT INTO table1 (field1,field2) SELECT 'value1','value2' WHERE NOT EXISTS (SELECT field1,field2 FROM table1 WHERE field1='value1');
About this entry
You’re currently reading “Postgres: Insert if not exist, else Ignore,” an entry on Faris Madi
- Published:
- 2009-03-13 / 10:09 pm
- Category:
- Programming, linux, web
- Tags:

No comments yet
Jump to comment form | comment rss [?] | trackback uri [?]