我有2张桌子
Table A
address_id email
12341 aba@mail.com
12342 abb@mail.com
12343 abc@mail.com
12344 abd@mail.com
12345 abe@mail.com
12346 abf@mail.com
12347 abg@mail.com
12348 abh@mail.com
12349 abi@mail.com
Table B
address_id email
12342 xyz@mail.com
12344 xyy@mail.com
12349 xyx@mail.com
Run Code Online (Sandbox Code Playgroud)
我想用表 B 中 address_id 匹配的电子邮件更新表 A 中的电子邮件。
我试过下面的查询:
update TableA A
set email=(select email from TableB B where A.address_id=B.address_id)
Run Code Online (Sandbox Code Playgroud)
但是它将所有电子邮件更新为 null,其中 address_id 在 TableA 中不匹配。
感谢你的帮助..