You can't specify target 'table' for update in FROM clausemysql
个人sql语句是这样的(简化版):sql
update A
code
set type= 0
cdn
where id in
blog
(select a.id from A a,B b where a.bId= b.id and b.mId=#{mId} and a.tel=#{tel});
ci
在作更新操做的时候,又作了一次表内查询,这显然会致使必要的字段被隐式复制到临时表中。get
解决方案it
多作一次A表的查询,为了让A的临时表不冲突,将sql语句改动一下:io
update A
table
set type= 0
where id in
(select a.id from (select id,bId,tel from A) a,B b where a.bId= b.id and b.mId=#{mId} and a.tel=#{tel});
ps:这个新的查询语句,只将表A中的几个字段查出来做为临时表,而不是整个表A做为临时表
从新执行:
问题解决
您的点赞和关注是对我最大的支持,谢谢!