我的查询是: -
delete from api_data
WHERE local_id NOT IN( SELECT MAX(local_id)
FROM api_data
GROUP BY local_id);
但我收到的错误是:
您无法在FROM子句中为更新指定目标表'api_data'。
任何帮助?
答案 0 :(得分:3)
在MySQL中,您无法从您选择的同一个表中删除。但是你可以使用另一个子查询来覆盖
delete from api_data
WHERE local_id NOT IN
(
select * from
(
SELECT MAX(local_id) FROM api_data GROUP BY local_id
) tmp
);