MainelyDesign.com Blog

MySQL - Determine Duplicate Rows Based on Multiple Fields/Columns

Posted on 03/17/2014 at 11:02 am by Kevin Wentworth
Viewed 10,243 times | 0 comments

I've been looking for some magical mysql query code to allow me to detect duplicate records, based on multiple columns being the same

MySQL Query to Detect Duplicate Rows (based on multiple fields)

  1. SELECT * FROM screwed_up_table GROUP BY field1, field2 HAVING count(*) > 1

That's it. Piece of cake.

I usually use this code to get the values of the duplicate rows, so I can create a user-level correction tool.

-Kevin

Bookmark and Share

Tags for MySQL - Determine Duplicate Rows Based on Multiple Fields/Columns

Database | Mysql | Web Programming

Comments for this Posting

No comments. Be the first to post a reply.

Sorry, comments are closed for this posting.

Please Email Kevin if you have any questions. Thanks!

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design