I have a datable like above and in that, unfortunately, repetitions occurs. How can I remove the repeated combination of 2nd, 3rd and 4th column and I need to make those three columns unique in combination.
Please help to write a query to do this, because there are 13000+ rows, so manual editing is hardly not possible.
Thanks in advance!
Best Answer
When finished, be sure to add this so dup rows won't recur:
Plan A:
For that query (and assuming it does the desired task), it would help to have
INDEX(exam, name, subject, id)
.Suggest you test it in a safe way... Create another table and try it there.
If not right,
DROP TABLE test
and try again.If looks good, then finish by moving the good result into place:
Plan B:
(Again, you should probably test it on a copy.)
Plan C: Even simpler, assuming you don't care what data you get for the extra columns:
That is, it won't necessarily give you the first
id
. You may need a particular setting to turn off "only full group by" if you have a 'new' version of MySQL.