I have Table A
and Table B
. I need to update Table B
email address matching with Table A
CUSTOMER_ID
. But before updating Table B
I need to check if the same email address exists with another CUSTOMER_ID
in the table Table B
don't update that email address.
example tables
Table A
CUSTOMER_ID PRIMARY_FLAG ACTIVE_FLAG FORMATTED_PHONE_ADDRESS
1033695 Y Y abcxyz@sproule.com
1076561 Y Y utam@gmail.com
1099936 Y Y peiman@gmail.com
1191873 Y Y abdulhakim@redmail.com
1297902 Y Y kbibault@hotmail.ca
1310143 Y Y chikwcj@chevron.com
1316231 Y Y marco.nieto@bestmail.com
1563840 Y Y aghafour@live.com
1650308 Y Y surajeetrath@yahoo.co.in
1701499 Y Y osamaelbakly@gmail.com
Table B
CUSTOMER_ID PRIMARY_EMAIL_ADDRESS
1033695 abcxyz12@hotmail.com
1076561 NULL
1099936 NULL
1191873 peiman@gmail.com
1297902 abdulhakim.nahdi@aramco.com
1310143 chikwcj@gmail.com
1316231 NULL
1563840 NULL
1650308 aghafour@live.com
1701499 osamaelbakly@egas.com.eg
I want result like
Update only non-duplicate email address
Update CUSTOMER Table
CUSTOMER_ID PRIMARY_EMAIL_ADDRESS
1033695 abcxyz@sproule.com
1076561 utam@gmail.com
1310143 chikwcj@chevron.com
1316231 marco.nieto@bestmail.com
1701499 osamaelbakly@gmail.com
I hope My question is understand