I’m trying to insert an array of new contacts from a temporary import table into our primary customer database. Before it is inserted, we want to first check if the contact exists on our blacklist. If it does exists, we do not want to insert it into the primary table.
I first pull the contacts from temp table:
SELECT `email` FROM `import_contacts`
Then I want to insert those contacts into the primary table ONLY AFTER it has been “scrubbed” or checked against the blacklist. The way I have it currently:
INSERT INTO `contacts` (`email`)
VALUES ('".implode("','','',''),('",$email)."','','','')
WHERE...
I got confused when it occurred to me that imploding the array like I have implodes ALL contacts, including those on the blacklist. So even if I were to get the WHERE statement to work, it would be wasteful and full of ambiguous data.
Is there a way to insert the contacts into the primary table after it has been checked against the blacklist table using one sql statement?
Any help would be greatly appreciated!!
1 Answer