1. 程式人生 > >錯誤:You can't specify target table 'xxx' for update in FROM clause的解決

錯誤:You can't specify target table 'xxx' for update in FROM clause的解決

參考:https://www.cnblogs.com/pcheng/p/4950383.html

 

解決:

 

程式碼:

<!-- 執行"取消收藏" 操作 -> 根據前端傳入的商品id和session中的id確定要刪除的物件 S -->
    <delete id="cancelCollect" parameterType="Integer">
        delete from collect where collect_id in (select c.collect_id from( select collect_id from collect where id = #{sessionId} and introduction_id = #{id}) c);
    </delete>
    <!-- 執行"取消收藏" 操作 -> 根據前端傳入的商品id和session中的id確定要刪除的物件 E -->