Table structure and content
Create Table If Not Exists 'Student '('id' Int ( 11 ) Not Null Auto_increment, 'name' Varchar ( 10 ) Not Null , 'Subobject' Varchar ( 10 ) Not Null , 'Score' Int ( 11 ) Not Null , Primary Key ('Id ')) Insert Into 'Student '('id', 'name', 'subobject', 'score ') Values ( 1 , ' James ' , ' English ' , 80 ),( 2 , ' James ' , ' Mathematics ' , 79 ),( 3 , ' James ' , ' Chinese ' , 81 ),( 4 , ' Xiaogang ' , ' English ' , 80 ),( 5 , ' Xiaogang ' , ' Mathematics ' ,80 ),( 6 , ' Xiaogang ' , ' Chinese ' , 80 ),( 7 , ' Xiaohong ' ,' English ' , 90 ),( 8 , ' Xiaohong ' , ' Mathematics ' , 90 ),( 9 ,' Xiaohong ' , ' Chinese ' , 81 );
SQL statement:
# Method 1 Select Name From Student Group By Name Having In (Score) > 80 # Method 2 Select Distinct Name From Student Where Name Not In ( Select Name From Student Where Score < 80 ) # Method 3 Select Name From Student Where Score > 80 Group By Name Having Count ( * ) > 1