兩個表
table1(id, c1, c2) table2(id, bm, mc)
c1,c2的數據源來自table2的mc列,且c1 c2列中的內容完全一致(每行的數據都相等)。現在想把c1和c2變成其所對應mc的bm列。寫sql語句
update table1
set table1.c1 = table2.bm
where table1.c2 = table2.mc
sql2008提示(下劃線部分)無法綁定由多個部分組成的標示符 table2.bm table2.mc
這個問題完全是邏輯問題導致的。不是給table2加個中括號比如 [table2]就能解決的。
換個寫法
udpate table1
set a.c1 = b.bm
from table1 a, table2 b
where a.c2 = b.mc
問題解決。