So I screwed up and filled a table with duplicate rows… I have a table something like this (actually THOUSANDS of somethings like this 🙁 ) :
id gname pname value
1 15 13 test
2 15 13 test
3 15 13 test
4 18 18 test
5 18 18 test
6 18 18 test
This table is only supposed to allow one row of the same gname, pname and value.
So now I need to write some sql that will group all these common rows together and delete them all except ONE! Argh!
Can anyone help me, STEP ONE, I believe is just to get a statement to return all the groups of duplicates.
** BTW – I know this is totally jacked. This is a very old system that I inherited and a big client this is using this… so I’m aware of the issues. I can fix the code that caused this ONCE I get the db back to the way its supposed to be.
Thanks!
If
idis unique and auto-incrementing this is easy:Do a
SELECTfirst, though.