mysql - 删除 : You can't specify target table 'table_name' for update in FROM clause

标签 mysql sql-delete

<分区>

我正在使用以下查询来删除不在另一个表中的数据。

delete from table_1 where tbl_id in  
(select tbl_id from table_1 left join table_2
on table_1.tbl_id=table_2.another_tbl_id where table_2.another_tbl_id is null)

上面的查询有问题吗?

它显示 You can't specify target table 'table_1' for update in FROM clause.

如何解决这个问题?

最佳答案

解决了我的问题。

我修改了上面的查询如下:

delete from table_1 where tbl_id not in  
(select another_tbl_id from table_2)

感谢您的所有回复...

关于mysql - 删除 : You can't specify target table 'table_name' for update in FROM clause,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23751934/

相关文章:

mysql - 删除索引高于 X 且具有相同值的行

c# - 如何删除具有相同相册 ID 的所有图像文件?

mysql - 处理存储过程中 select 语句返回的行

PHP,日期函数的使用

mysql - PHP MYSQL 删除一定数量(5)行

加入时删除mysql?

sql - SQL Server 一段时间后自动删除一条记录?

php - 使用 mysql 列的数字名称对 mysql 进行 PDO 查询。如何正确执行

mysql - 使用 MySQL 返回倒数第二个条目

php - 查询以获取列的差异