我有下面的查询,这是预期的工作。并返回需要删除的行。
SELECT * FROM tests WHERE e2e_product_id=407 AND test_name='PWBAR-FullBalance-Auth-TC1' AND
test_id<>(SELECT MAX(test_id)AS testid FROM tests WHERE test_name IN
(SELECT test_name FROM tests WHERE e2e_product_id=407 GROUP BY test_name HAVING COUNT(*) >1) AND e2e_product_id=407 GROUP BY test_name)
我刚刚将上面的查询更改为delete语法,但它返回异常
Delete FROM tests WHERE e2e_product_id=407 AND test_name='PWBAR-FullBalance-Auth-TC1' AND
test_id<>(SELECT MAX(test_id)AS testid FROM tests WHERE test_name IN
(SELECT test_name FROM tests WHERE e2e_product_id=407 GROUP BY test_name HAVING COUNT(*) >1) AND e2e_product_id=407 GROUP BY test_name)
错误:
错误代码:1093不能在from子句中指定更新的目标表“tests”
如何使用上述方法删除数据。有线索吗?
2条答案
按热度按时间whlutmcx1#
把你的钥匙换成你的钥匙
olmpazwi2#
我想你可以试试这个-