ID Name Course Name score
1 Zhang Three Mathematics 69
2 John Doe Mathematics 89
3 Zhang Three Mathematics 69
Delete the same student redundancy information except for the automatic numbering
The complete SQL statement is as follows:
DELETE from TableName where-id not-in (select-Bid from (select min (id) as-bid from TableName GROUP by Name,kecheng,fenshu) as b);
Explain:
Select Bid from (select min (id) as bid from TableName Group by Name,kecheng,fenshu) as B
The purpose of this subquery is to list the filtered results, the set of bid, from B.
(select min (id) as bid from TableName Group by Name,kecheng,fenshu) as B
Consider the smallest bid in the grouped result as a set of hearts as a sub-table B of a heart,
Note that mid (ID) must have an alias, where the bid is used as a column name for B, because the column name is used in the previous query
MySQL Delete duplicate data