[0816] Testing

1  # Query student in Article 2 to 4 data
 2  the SELECT  *  the FROM student limit 1 , 4 ;
 3  
4  # query for all students to learn from the student table number, name and faculty
 5  the SELECT the above mentioned id, `name`, Department the FROM student;
 . 6  
. 7  # computer science students and English-based query from the student table
 . 8  the SELECT `name`, Department the fROM student the WHERE Department the iN ( ' computer Science ' , ' English department ' );
 . 9  
10 # student table query from the age of 18 - 22-year-old student information
 11 The SELECT ID, `name`, Sex, 2019 - Birth the AS Age, Department, address the FROM student the WHERE   2019 - Birth the BETWEEN   18 is  the AND  22 is ;
 12 is  
13 is  # table query from a student how many people in each department
 14  the SELECT Department, COUNT ( ID) the fROM Student the GROUP  BY Department;
 15  
16  # query from the highest score for each subject Score table
 . 17  the SELECT c_name, MAX (Grade) the fROM Score the GROUP  BY c_name;
 18 is 
19  # John Doe query test subjects
 20  the SELECT c_name, Grade the FROM Score the WHERE stu_id = ( the SELECT the above mentioned id the FROM Student   the WHERE name =  ' John Doe ' );
 21  
22  # query names of all students, faculty, subjects connected with the manner and test scores
 23  the SELECT student.Id, `name`, Sex, Birth, Department, address, c_name, Grade the FROM student, score the WHERE student.id = score.stu_id;
 24-  
25  # calculate each student's total score of
 26  the SELECT student. the above mentioned id, `name`, SUM (Grade)The FROM Student, Score   the WHERE student.Id = score.stu_id the GROUP  BY ID;
 27  
28  # calculates the average score for each test subject
 29  the SELECT c_name, AVG (Grade) the FROM Score the GROUP  BY c_name;
 30  
31 is  # computer query score less than 95 student information points
 32  the SELECT  * the FROM student the WHERE ID the iN ( the SELECT stu_id the FROM Score the WHERE c_name = ' computer '  the AND Grade <95 );
 33  
34  Student Information # inquiry also participate in computer and English test
 35  the SELECT  *  the FROM Student the WHERE the above mentioned id = the ANY ( the SELECT   stu_id the FROM Score the WHERE stu_id the IN ( the SELECT stu_id   the FROM Score the WHERE c_name = ' computer ' ) the AND c_name = ' English ' );
 36  
37 [  # computer sorted in descending examination results
 38 is  the SELECT stu_id, grade the FROM scoreThe WHERE c_name =  ' computer '  the ORDER  BY Grade DESC ;
 39  
40  # query from a student table and the score table school student number, and then merging the query results
 41 is  the SELECT ID   the FROM student the UNION  the SELECT stu_id the FROM score;
 42 is  
43 is # query or Zhang classmate Wang's name, department and test subjects and grades (suggesting, for example like fuzzy query keyword query to selec names beginning with a *  from table name the WHERE name like 'a % ')
 44  the SELECT student.Id, `name `, Sex, Birth, Department, Address, c_name, Grade the FROM Student, ScoreThe WHERE ( `name` the LIKE   ' Zhang% '   OR ` name` the LIKE   ' King% ' ) the AND student.id = score.stu_id;
 45  
46  # queries are students of Hunan's name, age, faculty and test subjects and grades
 47  the SELECT student.Id, `name`, Sex, Birth, Department, the Address, c_name, Grade the FROM Student, Score the WHERE the Address the LIKE  ' Hunan% '  the AND student.id = score.stu_id;

 

Guess you like

Origin www.cnblogs.com/yanglanlan/p/11363109.html