美文网首页Java 核心技术MySQL
You can't specify target tab

You can't specify target tab

作者: sakura_L | 来源:发表于2017-10-09 15:10 被阅读15次

delete from device where id =
(select d.id FROM device d LEFT JOIN river_chief rc on rc.river_id = d.river_id
LEFT JOIN chief c on c.id = rc.chief_id
WHERE c.user_id = '1' AND d.id ='#')

You can't specify target table 'device' for update in FROM clause 因为直接到的device表中的id , 在mysql中无法直接通过这种方式操作, 需要通过中间表来操作。
delete from device where id in
(select a.id from
(select d.id FROM device d LEFT JOIN river_chief rc on rc.river_id = d.river_id
LEFT JOIN chief c on c.id = rc.chief_id
WHERE c.user_id = '1' AND d.id ='c2ce10f7c59049fc8bb686866daf0ba4') a
)

相关文章

网友评论

    本文标题:You can't specify target tab

    本文链接:https://www.haomeiwen.com/subject/dohpyxtx.html