有兩張表,info1, info2 ,
info1:

info2:

現在,要用info2中的資料更新info1中對應的學生資訊,sql陳述句如下:
UPDATE info1 t1 JOIN info2 t2 ON t1.name = t2.name SET t1.age = t2.age, t1.class = t2.class;
運行結果如下:

更新過的info1:

至于效率問題,之前我有三張表,都在40萬左右,需要將 table2 中的兩個欄位(step1),table3 中的一個欄位(step2),更新到 table1 中,step1 用時半個小時左右,而 step2 用了兩個多小時,不知為何,三個表都根據一個相同欄位建立了唯一索引,
本人裝了 navicat 破解版,垃圾,有時候越著急,就越是卡,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/234685.html
標籤:其他
