我正在运行查询来删除重复的条目。它无需 LIMIT 语句即可工作,但会使服务器过载。我想使用 LIMIT 语句对其进行批处理。
DELETE t1
FROM data as t1
join data as t2
WHERE t1.type = t2.type
AND t1.timestamp = t2.timestamp
LIMIT 100
使用 LIMIT 语句会收到错误:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 100' at line 6
最佳答案
您不能直接使用可以在选择中使用的删除限制
DELETE data
FROM data as t1
join (
select distinct type, timestamp from data limit 100
) t2 on t1.type = t2.type AND t1.timestamp = t2.timestamp
关于MySQL DELETE with JOIN 使用 LIMIT 语句获取语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45618389/