Delete The same student redundancy information except the ID number
2. The student table is as follows :
ID number Study number name course number Course name score
1 2005001 Zhang San 0001 Mathematics 69
2 2005002 John Doe 0001 Mathematics 89
3 2005001 Zhang San 0001 Mathematics 69
Create TableStudent2 (IDintAuto_incrementPrimary Key, codevarchar( -), namevarchar( -));Insert intoStudent2Values(NULL,'2005001','Zhang San'),(NULL,'2005002','John Doe'),(NULL,'2005001','Zhang San');//in the following statement, MySQL reports errors and may delete dependent statistical statements, which in turn result in inconsistent statistical statement results. Delete fromStudent2whereId not inch(Select min(ID) fromStudent2Group byname);//However, there is no problem with the following statement:Select * fromStudent2whereId not inch(Select min(ID) fromStudent2Group byname);//So, I want to first put the result of the group into a virtual table, and then select the result from the virtual table, and finally the result as the deletion of the condition data. Delete fromStudent2whereId not inch(SelectMid from(Select min(ID) Mid fromStudent2Group byName ast); or:Delete fromStudent2whereId not inch
(Select min(ID) from
(
Select * fromStudent2) asTGroup byT.name);
Delete the same student redundancy information except the ID number