I'm trying to do something with the duplicate records in a mysql database. however, I don't want to delete the records, and only two columns are duplicate. How can I find just these records?
can you post more information about the table structure and what do you mean that some are duplicate but only by two columns ?
Anyway, you can look into the GROUP BY
, COUNT
, and HAVING
SELECT `duped_field1`, `duped_field2`, COUNT(*) `tot`
FROM `table`
GROUP BY `duped_field1`, `duped_field2`
HAVING `tot` > 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With