Query to return all rows which are duplicates MYSQL

phdit
phdit used Ask the Experts™
on
Good Afternoon,
I have a MYSQL table where I need a query to identify any duplicate rows the entire row so all column's need to be the same.  The best I have come up with is the below but its not functioning correctly.

SELECT Customer, Department_user, Plex, Colour, Pages, Envelope, Date, Postal, EnvelopeType, SystemVersion, DateTime, COUNT(EnvelopeType) AS Occurance_Count
FROM        Epod
GROUP BY Customer, Department_user, Plex, Colour, Pages, Envelope, Date, Postal, EnvelopeType, SystemVersion, DateTime
HAVING     (COUNT(EnvelopeType) > 1)

Thanks

John H
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Not functioning correctly how? What is doing / not doing that you expect it to?

I use the following to find duplicates

SELECT COUNT(*), field1, field2, ...
FROM tablename
GROUP BY field1, field2, ...
HAVING COUNT(*) > 1

Open in new window


Which works for me - to help you we need to know what your query is not doing.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial