SQL: doppelte Datensätze finden
9. Februar 2010
Kommentare ausgeschaltet
Will man auf einer Tabelle in nachhinein einen Key über mehrere Felder anlegen, scheitert das machmal an doppelten Datensätzen. Mit folgendem Schnippsel kann man doppelte Datensätze finden:
Hier ein Beispiel für eine Zelle
SELECT domain, COUNT(domain) AS NumOccurrences
FROM domains
GROUP BY domain
HAVING ( COUNT(domain) > 1 )
FROM domains
GROUP BY domain
HAVING ( COUNT(domain) > 1 )
Hier ein Beispiel für einen Schlüssel über mehrere Zellen:
SELECT domain, subdomain, email, COUNT(domain) AS NumOccurrences
FROM domains
GROUP BY domain, subdomain, email
HAVING ( COUNT(domain) > 1 AND COUNT(subdomain) > 1 AND COUNT(email) > 1)
FROM domains
GROUP BY domain, subdomain, email
HAVING ( COUNT(domain) > 1 AND COUNT(subdomain) > 1 AND COUNT(email) > 1)
Popularity: 3% [?]
Twitter It!