I have 2 tables which have names and emails. Now I want to merge these tables into a new table without duplicate records. I want to use email fields for avoiding duplicate values in both tables. I heard INSERT IGNORE query is using for inserting values into a table without affecting existing records. How to write INSERT IGNORE query to check email field for duplication checking. If anyone knows other methods are also welcome.
table1:
fid fname email
--- ----- -----
1 Balaji balaji@email.com
2 xxxxx xxxxx@email.com
3 Bala bala@email.com
table2:
gid gname gemail
--- ----- ------
1 Bala bala@email.com
2 vinoth vinoth@email.com
Expected result:
table3:
-------
id name email
-- ---- -----
1 Balaji balaji@email.com
2 xxxxx xxxxx@email.com
3 Bala bala@email.com
4 vinoth vinoth@email.com