现在的位置: 首页 > 综合 > 正文

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

2013年09月08日 ⁄ 综合 ⁄ 共 174字 ⁄ 字号 评论关闭

在MYSQL中,我们可是使用以下update语句对表进行更新:

update a set a.xx= (select yy from b) where a.id = b.id ;

但是在mysql中,不能直接使用set select的结果,必须使用inner join:

update a inner join (select yy from b) c on a.id =b.id  set a.xx = c.yy

抱歉!评论已关闭.