2012-08-02 116 views
0

我有表A &表B。我需要更新TableA.custid,其值(1 - 8),這樣我就可以反映TableB.namesMysql更新table1從表2值與CASE

爲了更清楚

TableA.custid = 1,當TableB.name = '艾倫格雷' TableA.custid = 2,當TableB.name ='Alex Watt'

TableA和TableB得到相同的記錄數。而2之間的關係是TableA.id = TableB.id

這將是什麼語法?

回答

0
Update tableA as t1 inner join TableB as t2 
on t1.id=t2.id 
set t1.name=t2.name