mysql查询删除记录后选择?

pw9qyyiw  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(309)

这个问题在这里已经有答案了

mysql错误1093-无法在from子句中指定更新的目标表(16个答案)
两年前关门了。
选择记录后,我想删除该记录..我尝试了以下查询-(删除后) ,MAX(value) 但是它的显示-不能在from子句中为update指定目标表“test”

DELETE FROM test WHERE ext_no IN 
(
SELECT   ext_no, MAX(value)
FROM     test
GROUP BY ext_no
HAVING   COUNT(*) > 2 AND 
         COUNT(*) = COUNT(CASE value WHEN 0 THEN 1 END)
);
jslywgbw

jslywgbw1#

您可以在下面尝试-您需要对内部select语句使用子查询

DELETE FROM test WHERE ext_no IN 
(
select ext_no from
(
SELECT   ext_no, MAX(value)
FROM     test
GROUP BY ext_no
HAVING   COUNT(*) > 2 AND 
         COUNT(*) = COUNT(CASE value WHEN 0 THEN 1 END)
)t)

相关问题