I made a mistake and I have unwanted duplicates.
I have a table with 4 key fields. A1
, k1
, k2
, k3
.
A1
is auto increment and the primary key.
the combination of k1
, k2
and k3
is supposed to be unique and I have to delete the duplicate rows before I create a unique index. Some rows have one duplicate, some have many.
SELECT CONCAT(k1, k2, k) AS dup_value
FROM myviews
GROUP BY dup_value
HAVING (COUNT(dup_value) > 1)
shows me duplicates values that I need to deal with. But now I don't know how to keep one and delete the rest of each duplicate set.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…