[Err] 1093 - You can't specify target table 'master_data' for update in FROM clause
Posted lizzzzz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Err] 1093 - You can't specify target table 'master_data' for update in FROM clause相关的知识,希望对你有一定的参考价值。
delete from master_data where category_id not in (
select category_id from master_data a, bc_category b where a.category_id=b.cate_id
)
执行SQL语句时出现这个错误。原因是在更新这个表和数据时又查询了它,而查询的数据又做了更新的条件。以前ORACLE上面没有这个错误。
上面这个语句其实没有写好 不优化了
直接更新
delete from master_data where category_id not in(select category_id from (
select category_id from master_data a, bc_category b where a.category_id=b.cate_id
) tmp);
注:将查询出来的数据做一个第三方表进行管理
以上是关于[Err] 1093 - You can't specify target table 'master_data' for update in FROM clause的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 5.7 错误 (1093: You can't specify target table ___ for update in FROM 子句) - 通常的解决方案不起作用
npm i安装包依赖时 gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env(
npm i安装包依赖时 gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env
If you only do what you can do you'll never be more than you are now.
You can't specify target table 'Person' for update in FROM clause