如圖,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 )