Find Duplicates in MySQL
eharetea

Finding duplicate entries in a MySQL column.

Find duplicate rows in MySQL.

Date Created:Sunday August 03rd, 2008 01:31 PM
Date Modified:Monday May 10th, 2010 08:00 PM

Duplicate entries

Below are some queries to find duplicates. The group by clause is very important in these types of queries.
SELECT folder_id, 
 COUNT(folder_id) AS Number
FROM page_settings
GROUP BY folder_id
HAVING ( COUNT(folder_id) > 1 )

SELECT email
FROM users as u, hits as h
WHERE (h.uagent like '%MSIE%' AND u.user_id = h.user_id)
GROUP BY email
HAVING ( count(email) > 1) 

SELECT email, COUNT(email) as downloads
FROM users as u, downloads as d
WHERE (u.user_id = d.user_id)
GROUP BY email HAVING ( count(email) > 1) 


Downloads:
Download: duplicates.sql 407 B

Please login or Click Here to register for downloads
Creative Commons License
Find Duplicates in MySQL by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com