In this article, we will find out about copy records and the procedure to discover and erase them from the database.
In the event that the database isn’t overseen appropriately, at that point the records in the table can be copied, there is no uncertainty about it. Along these lines, the need to erase the records emerges, which can be minimal muddled.
We should comprehend the stuff to erase the copy information of a table. The First we need to do is to discover the fields that can have the copy records. What it implies is that, in the event that we have a thought regarding which fields contain the copy information we can take a shot at that all the more without any problem.
From that point forward, we should simply to choose the particular information. In the example given beneath, the copy things have been chosen with the assistance of id. What it implies is that we bunch records as per the name and afterward erase them.
Presently, erasing copy records is definitely not something beneficial for the database as we don’t have the foggiest idea whether the id of any of the records were utilized in some other record. This can cause a gigantic measure of weight if the free track of any record which has been utilized elsewhere. Hence consistently deal with these things previously.
Table (representative) having three fields and four information in it,
Id Name Address 100 Aman Mumbai 200 Arun Pune 300 Karan Delhi 400 Aman Mumbai
In above table, we have a copy passage of name “Aman” where the email is likewise same, presently we will make an inquiry to erase the copy push in the database and afterward select all records to demonstrate them to discover the update work appropriately.
Query:
DELETE FROM employee WHERE id not in (select min(id) FROM employee GROUP BY name, address);
Display table records.
SELECT * FROM employee;
Output: