mysql update不能直接使用select的结果
在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
本文对比了MySQL和SQL Server中使用update语句进行表更新的方法,特别是当使用select结果作为更新条件时的语法差异,并通过实例展示了如何在MySQL中实现类似SQL Server的操作。
408

被折叠的 条评论
为什么被折叠?



