您的位置:首页 > 数据库 > MySQL

mysql update不能直接使用select的结果

2016-04-25 10:53 447 查看
在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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: