table1
id name
1 张三
2 李四
3 王五
(此表ID号唯一,且不为空)
table2
id name
1 空
空 空
2 空
2 空
(此表ID列值不唯一,也有可能为空)求助:如何将table2表中ID号与table1一致的name替换成table1表中的nmae,期望结果如下:
table2
id name
1 张三
空 空
2 李四
2 李四
id name
1 张三
2 李四
3 王五
(此表ID号唯一,且不为空)
table2
id name
1 空
空 空
2 空
2 空
(此表ID列值不唯一,也有可能为空)求助:如何将table2表中ID号与table1一致的name替换成table1表中的nmae,期望结果如下:
table2
id name
1 张三
空 空
2 李四
2 李四
set a.name=
(
select b.name from table1 b where a.id=b.id
)
where exists
(
select 1 from table1 b where a.id=b.id
)