Mysql deletes the record statement bitsCN.com in the subquery.
Mysql deletes record statements in a subquery.
SQL code delete from t_5star where locationid in (select e. locationid from (select a. * from t_5star as a, t_als_data as B where a. term = B. term) e)
The key is to place the statements in the subquery into a single e table.
How to query and delete duplicate records
(1)
1. search for redundant duplicate records in the table. duplicate records are determined based on a single field (peopleId ).
SQL code select * from people where peopleId in (select peopleId from people group by peopleId having count (peopleId)> 1) 2. delete unnecessary duplicate records in the table, repeat Records are determined based on a single field (peopleId). only the records with the smallest rowid are retained: delete from peoplewhere peopleId in (select peopleId from people group by leleid having count (peopleId)> 1) and rowid not in (select min (rowid) from people group by peopleId having count (peopleId)> 1) 3. search for redundant duplicate records in the table (multiple fields) select * from vitae awhere (. peopleId,. seq) in (select peopleId, seq from vitae group by peopleId, seq having count (*)> 1) 4. delete redundant record (multiple fields) in the table ), delete from vitae awhere (. peopleId,. seq) in (select peopleId, seq from vitae group by peopleId, seq having count (*)> 1) and rowid not in (select min (rowid) from vitae group by peopleId, seq having count (*)> 1) 5. search for redundant duplicate records (multiple fields) in the table, excluding the records with the smallest rowid select * from vitae awhere (. peopleId,. seq) in (select peopleId, seq from vitae group by peopleId, seq having count (*)> 1) and rowid not in (select min (rowid) from vitae group by peopleId, seq having count (*)> 1)
(2)
For example
There is A field "name" in table ",
The "name" value may be the same for different records,
Now you need to query the records in the table, and the "name" value has repeated items; Select Name, Count (*) From A Group By Name Having Count (*)> 1. if the sex is also the same, Select Name, sex, Count (*) From A Group By Name, sex Having Count (*)> 1
BitsCN.com