需求:
我需要从tableA之中找到name字段的Filter的记录,得到此记录的id,然后根据id删除tableA中的该条记录;
-- 但是我使用如下xql语句的时候delete from tableA where id in (select id from tableA where tableA.name = 'Filter');
报错:Error Code: 1093. You can’t specify target table ‘quesans’ for update in FROM clause
解决:
先建立一张临时表tmp;
select id from (select id from tableA where name= ‘Filter’) tmp;
然后删除:
delete from tableA where id in (select id from (select id from tableA where name= ‘Filter’) tmp);
参考文章:
Original: https://www.cnblogs.com/cjin-01/p/16709781.html
Author: 2337
Title: delete语句嵌套-mysql
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/712602/
转载文章受原作者版权保护。转载请注明原作者出处!