苏州市律师事务所排名:关于sql语句中update的问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/27 17:30:56
现有两张表table_all table_new 都含有字段name和phoneNo
table_new 中name是table_all的子集
现需要根据table_new中phoneNo的内容更新table_all
请问如何操作

例如:
table_all内容:
name phoneNo
a 123
b 234
c 345
d 456

table_new:
name phoneNo
a 987654
b 456789

操作后的结果:
table_new不变

table_all变为:
name phoneNo
a 987654
b 456789
c 345
d 456

谢谢

update table_all a set a.phoneNo=b.phoneNo from table_new b where a.name =b.name