我有兩個表a1和a2
a1:結構和數據是
xh numb
1 null
2 null
a2:結構和數據是
ID sm
1 1.1
2 2.5
a1中的numb 和a1中的sm字段都是float,我現在想把a2中的sm數據更新到a1中numb的去,條件中ID想等,
我寫的是update a1 set numb=a2.sm where a1.id=a2.xh 可是不行
想請教怎麼寫最簡單!
update a1 set numb=a2.sm from a1,a2 where a1.id=a2.xh
Update A Set numb=B.sm from a1 A Inner Join a2 B On A.xh=B.ID
OR
Update A Set numb=B.sm from a1 A ,a2 B Where A.xh=B.ID
update a1 set a1.numb=a2.sm from a1,a2 where a1.xh=a2.id
from tn
where #t.tid=tn.tid
update a1 set numb=a2.sm
from a2
where a1.id=a2.id
update a1 set numb=a2.sm from a2,a1 where a1.xh=a2.id
update a1 set numb=(select sm from a2 where a1.xh=a2.id)