Let’s say I have two table table_new and table_old
table_old
ID email_address full_name address
-----------------------------------------
1 a@b.com john street 1
2 b@b.com peter street 2
3 c@b.com david street 3
table_new
ID email_address
----------------------
1 b@b.com
2 c@b.com
3 d@b.com
4 e@b.com
5 f@b.com
... ....
300 xyz@xux.com
Questions :
How do I copy the email address from table_new to table_old with some statement below
- If in
table_oldalready exists an email address fromtable_newignore it. - If in
table_newdoes not exists an email address fromtable_olddelete it.
So the result should be
table_old
ID email_address full_name address
-----------------------------------------
1 b@b.com peter street 2
2 c@b.com david street 3
3 d@b.com
4 e@b.com
5 f@b.com
... ....
300 xyz@xux.com
Let me know.
I guess it can be done in two queries.
Assuming id is an autoincrement key, otherwise id can be inserted and selected, along with email address.