在sql server,oracle中,我们可是使用以下update语句对表进行更新:
update a set a.xx= (select yy from b)
但是在mysql中,不能直接使用set select的结果,必须使用 inner joi
update a inner join (select yy from b) c set a.xx = c.yy
使用实例:
update virtualmachine v INNER JOIN (select vm.id from virtualmachine vm left join functionalci fi on vm.id=fi.id where locate('.',fi.name)<=0 ) c on v.id=c.id set v.category='VirtualDesktop'
update ( select dataresource
from KDTA_TA1130.ecpay_abnormalrcd
where businesscode = '98'
and dataresource = '0'
and ecno ='00682'
and abnormallevel = '1' ) t
set t.dataresource =9
本文探讨了在SQL Server和Oracle中直接使用SELECT子句进行更新的方法,并介绍了MySQL如何通过INNER JOIN实现相同功能。文中提供了具体示例,包括虚拟机分类更新和支付记录数据资源变更。

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



