Category: >> mySQL >> Find All Duplicate Rows Bookmark and Share

<< lastnext >>

Snippet Name: Find All Duplicate Rows

Description: A simple bit of SQL that finds duplicate rows in a table. Includes code to find a row that occurs once and only once.

Also see:
» Simple directory viewer / browser
» Recursive Directory Browser
» Make alternating color table rows ...
» Highlight table rows on rollover
» Converting Rows to Columns
» Dynamically Add/Remove rows in HTM...
» INDEXES: Unique indexes
» INDEXES: Single Column Non-unique
» Generate unique strings of random ...
» UPDATE: Update multiple rows
» Count rows in all tables
» List tables with more than 'X' rows
» Easy page browser
» Unique IP-icture
» Hierarchical categories browser
» Find all duplicates in a column
» Recursive Directory Browser
» Browser sniffer / detector
» Select distinct/unique entries
» Grouping rows by frequency
» Unique Constraint
» Counting rows
» Unique Array function
» Detect Mobile/WAP browser

Comment: (none)

Author: CoderZone
Language: MYSQL
Highlight Mode: MYSQL
Last Modified: February 26th, 2009

SELECT email, 
 COUNT(email) AS NumOccurrences
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 )
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 8