我使用下面的查询来删除异常值(是sd的1.5倍)。
DELETE FROM sv_condition_sw
WHERE snow_mountain > (
SELECT AVG(snow_mountain)+1.5*STDDEV(snow_mountain)
FROM sv_condition_sw
WHERE lud='2012-11-28' AND res_id=769)
AND lud='2012-11-28'
AND res_id=769
然而它出现了这个错误:
查询:delete FROM sv_condition_sw WHERE snow_mountain > (SELECT AVG(snow_mountain)+1.5*STDDEV(snow_mountain) FROM sv_condition_sw WHER...
Error Code: 1093
You can't specify target table 'sv_condition_sw' for update in FROM clause
我不知道这意味着什么。
答案 0 :(得分:3)
您可以使用另一个子选择
来欺骗MySQLDELETE FROM sv_condition_sw
WHERE snow_mountain > (select * from (SELECT AVG(snow_mountain)+1.5*STDDEV(snow_mountain)
FROM sv_condition_sw
WHERE lud='2012-11-28'
AND res_id=769) x)
AND lud='2012-11-28' AND res_id=769