/ Published in: SQL

Here's a handy query for finding duplicates in a table.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# Suppose you want TO find ALL email addresses IN a TABLE that exist more than once: SELECT email, COUNT(email) AS COUNT FROM users GROUP BY email HAVING ( COUNT(email) > 1 ) # You could also USE this technique TO find ROWS that occur exactly once: SELECT email FROM users GROUP BY email HAVING ( COUNT(email) = 1 )
URL: http://www.petefreitag.com/item/169.cfm
Comments
