Delete from ZQZRDP
where Tel in (select min (dpxx_id) from ZQZRDP GROUP BY Tel has count (tel) >1);
Run, error
The exception is: You cannot specify the update of the target table in the FROM clause. It's silly. MySQL writes like this, no, it makes people depressed.
It's just a step in the back of the egg.
The following is written by netizens. The same is the pit Daddy code, I can not execute on the machine.
1. Query the records that need to be deleted and keep a record.
code such as the following |
copy code |
select A.id,a.subject,a.receiver from Test1 a LEFT join (select C.subject,c.receiver, max (c.id) as bid from Test1 C where s Tatus=0 GROUP by Receiver,subject have count (1) >1) b on a.id< b.bid where A.subject=b.subject and A.receive R = B.receiver and a.ID < b.bid |
2. Delete repeated records, leaving only one record. Attention. Subject,receiver to index. Otherwise it will be very slow.
code such as the following |
copy code |
delete A from Test1 A, (select C.subject,c.receiver, max (c.id) as bid from test1 C where status=0 GROUP by Receiver,subject Having count (1) >1) b where a.subject=b.subject and a.receiver = B.receiver and a.ID < b.bid; |
3. Find redundant and repeated records in the table. The repeated recording is based on a single field (Peopleid) to infer the
code such as the following |
copy code |
select * From people where Peopleid in (select peopleid from people group by peopleId ; having count (Peopleid) > 1) |
4. Delete Redundant records in the table, repeated records are inferred from a single field (Peopleid). Only the smallest record of rowid is left
code such as the following |
copy code |
delete From people , where peopleid in (select peopleid from people group by peopleid having count (Peopleid) > 1) and rowID not in (select min (rowid) from people g Roup by peopleid have count (Peopleid) >1) |
5. Delete Redundant records (multiple fields) in a table. Only the smallest record of rowid is left
Code such as the following |
Copy Code |
Delete from Vitae a where (A.PEOPLEID,A.SEQ) in (select Peopleid,seq from Vitae GROUP by PEOPLEID,SEQ have count (*) > 1) and rowID not in (select min (rowid) from Vitae GROUP by PEOPLEID,SEQ have Count (*) >1) |
MySQL deletes repeated data in the database (whichever is the data)