http://qs1969.pair.com?node_id=11107746

haukex has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

My SQL-fu is too weak for this one and Google hasn't helped yet. I'm inserting data records into a table, and there will be lots of duplicates: if the primary key exists, it should silently ignore the record if all the other columns match, but throw an error if they don't. Basically, of the following, the second should be ignored and the third should throw an error. I feel like there should be an easy solution but I'm not seeing it yet.

INSERT INTO records (PriKey, Foo, Bar) VALUES (1, 'Hello', World'); INSERT INTO records (PriKey, Foo, Bar) VALUES (1, 'Hello', World'); INSERT INTO records (PriKey, Foo, Bar) VALUES (1, 'Hello', Quz');

Also, related: Since I can choose the DB, what is your opinion on MySQL vs. Postgres? I'm thinking I'll probably use the latter but would like to hear any opinions.