Supose I have a table with several columns.
I know how to find duplicates, and then to keep just one record with this expression, adding a combinated index…
ALTER IGNORE TABLE part3 ADD UNIQUE INDEX (gtu, region, trait, pop, author, risk)
…but I would like to be able to control which will be the deleted row; not just the one with the “first row of rows with duplicates on a unique key“, as stated here in the mysql doc.
I mean, i exactly want to specify that the non-deleted row must be the one with the minor value in column field called zvalue.
Any suggestion?? Is this possible?
Thanks!
Instead of trying to delete what you don’t need, try to think of it as a problem whereby you want to pick the ones you want and ignore the rest; like so:
That should create a table
other_tablethat satisfies the unique constraint in your data; only the rows with the highestzvalueare kept, the others removed (skipped).