I have 2 tables
Table A
address_id email
12341 [email protected]
12342 [email protected]
12343 [email protected]
12344 [email protected]
12345 [email protected]
12346 [email protected]
12347 [email protected]
12348 [email protected]
12349 [email protected]
Table B
address_id email
12342 [email protected]
12344 [email protected]
12349 [email protected]
I want to update emails in table A with emails in Table B where the address_id matches.
I have tried the below query :
update TableA A
set email=(select email from TableB B where A.address_id=B.address_id)
But its updating all the emails to null where the address_id is not matching in TableA.
Appreciate your help..
where
to the update. (I am not sure how the exist syntax in DB2 is)