在sql server中,我們可是使用以下update語句對表進行更新:
update a set a.xx= (select yy from b) ;
但是在mysql中,不能直接使用set select的結果,必須使用inner join:
update a inner join (select yy from b) c set a.xx = c.yy
例:
update mb_tariff a inner join
mb_tariff_temp b set a.payment = b.payment
where a.mybus_id = b.mybus_id
and a.tariff_id = b.tariff_id
UPDATE USER INNER JOIN (SELECT id,account FROM USER) c SET user.phone=c.account WHERE user.id = c.id

