Let’s say I have 2 tables in my database. users and combineusers
I want to insert current email on users to combineusers without have duplicate email.
INSERT INTO combineusers (Email)
SELECT Email FROM users
What is correct statement to skip existing email address on combineusers
Use a left exclusion join.
I’m not sure the subselect is needed, I know it’s needed on an update.
The subselect forces MySQL to materialize the inner select into a temp table and do the insert from there so that you’re not inserting into the same table your selecting from.