Find and remove duplicates: Difference between revisions
Jump to navigation
Jump to search
→Finding duplicate value that differ in one column
| Line 37: | Line 37: | ||
=== Find duplicates in MySQL === | === Find duplicates in MySQL === | ||
==== Finding duplicate value that differ in one column ==== | ==== Finding duplicate value that differ in one column ==== | ||
Finding duplicate value that differ in one column<ref>[http://stackoverflow.com/questions/688549/finding-duplicate-values-in-mysql?rq=1 Finding duplicate values in MySQL - Stack Overflow]</ref> | '''Finding duplicate value that differ in one column'''<ref>[http://stackoverflow.com/questions/688549/finding-duplicate-values-in-mysql?rq=1 Finding duplicate values in MySQL - Stack Overflow]</ref> | ||
<pre> | <pre> | ||
-- Generate test data. | -- Generate test data. | ||
| Line 64: | Line 64: | ||
) tmp | ) tmp | ||
WHERE tmp.count >1; | WHERE tmp.count >1; | ||
</pre> | |||
'''Another approach:''' Add {{kbd | key=content_hash}} column which its value is {{kbd | key=MD5(content_column)}} | |||
<pre> | |||
-- To find the duplicated records with same content | |||
SELECT count(*) as count, content_hash | |||
FROM `YOUR_TABLE_NAME` | |||
GROUP BY content_hash | |||
HAVING count >= 2 | |||
</pre> | </pre> | ||