我有一张这样的桌子:
Country_city('id', 'country_id', 'City_id')
并在其上复制我选择的记录:
SELECT
CONCAT(Country_id, '+', City_id),
COUNT(CONCAT(Country_id, '+', City_id))
FROM Country_City
GROUP BY CONCAT(Country_id, '+', City_id)
HAVING COUNT(CONCAT(Country_id, '+', City_id)) > 1
结果如下:
CONCAT(Country_id, '+', City_id) | COUNT(CONCAT(Country_id, '+', City_id))
MA07+11 | 48
MA07+13 | 5
...
我试图删除它们我执行这个:
DELETE FROM Country_City
WHERE id NOT IN (
SELECT MAX(id)
FROM Country_City
GROUP BY CONCAT(Country_id, '+', City_id)
);
它不工作;我的要求有什么问题吗?如何删除重复数据并保留一条记录?