我有一些地理编码的地址在我的SQL表中是重复的,我试图删除并只留下一个。我已经编写了以下代码:
SELECT
address`, COUNT(*)
FROM stores
GROUP BY address`
HAVING COUNT(*) > 1
但是,它只显示地址和显示重复的实际计数(即2),并且不允许我选择要删除的任何内容。我需要添加什么额外的sql命令来删除重复项?
答案 0 :(得分:0)
假设id
是表stores
DELETE FROM stores WHERE id NOT IN
( SELECT min FROM (SELECT MIN(id) AS min FROM stores GROUP BY address) AS T1)