我想删除此查询返回的记录:
SELECT SQL_CALC_FOUND_ROWS tag, COUNT( tag ) AS count
FROM _tags
GROUP BY tag
HAVING count = 1
ORDER BY count DESC
LIMIT 100;
我该怎么做?
答案 0 :(得分:1)
假设tag
为_tags
'主键:
DELETE _tags.* FROM _tags
JOIN (
SELECT tag FROM _tags GROUP BY tag HAVING COUNT(tag) = 1 LIMIT 100
) AS subq USING (tag)
不确定“SQL_CALC_FOUND_ROWS删除”是什么意思。如果您只想知道有多少记录符合您的条件而忽略LIMIT
子句,那么您应首先运行SELECT
。