如图,t1,t2表,我想通过t2来更新t1的name,试着写了一个
update t1 a set a.name=(select b.name from t2 b where a.id=b.id)
但这样的话,在t2中不存在的id=3的name就会成空,该怎么写呢?

如图,t1,t2表,我想通过t2来更新t1的name,试着写了一个
update t1 a set a.name=(select b.name from t2 b where a.id=b.id)
但这样的话,在t2中不存在的id=3的name就会成空,该怎么写呢?

update t1 A a set name= ( select b.name from t2 B where ID = a.ID )
where exists(select t2 1 from B where ID = a.ID )