I've got a table for a mailing list web application, containing a column for the email address and a column for the List ID.
I need to run through an uploaded CSV file, adding new records for new email addresses for the selected list ID.
I can only see a way to do this using two queries, one to see if there are any existing records and another to do the actual insert (if there aren't):
SELECT id FROM tblContacts WHERE listID = 123 and email = 'me@web.com'
INSERT INTO tblContacts (listID, email) VALUES (123, 'me@web.com')
Is there a way to do it with just the one?