Skip to main content
2 of 3
added 244 characters in body
ypercubeᵀᴹ
  • 98.7k
  • 13
  • 215
  • 305

There's probably a more elegant way to do it but this should only update the matching rows:

update TableA A 
set email = (select email from TableB B where A.address_id = B.address_id)
where exists
      (select 1 from TableB B where A.address_id = B.address_id) ;

Another option is to use MERGE:

MERGE INTO TableA AS A
USING
  ( SELECT address_id, email
    FROM TableB
  ) AS B
  ON A.address_id = B.address_id
WHEN MATCHED THEN
  UPDATE SET email = B.email ;
ypercubeᵀᴹ
  • 98.7k
  • 13
  • 215
  • 305