当前位置:网站首页>MySQL multi table query
MySQL multi table query
2022-07-27 01:53:00 【Palm nine】
material :
establish student and score surface
CREATE TABLE student (
id INT(10) NOT NULL UNIQUE PRIMARY KEY ,
name VARCHAR(20) NOT NULL ,
sex VARCHAR(4) ,
birth YEAR,
department VARCHAR(20) ,
address VARCHAR(50)
);
establish score surface .SQL The code is as follows :
CREATE TABLE score (
id INT(10) NOT NULL UNIQUE PRIMARY KEY AUTO_INCREMENT ,
stu_id INT(10) NOT NULL ,
c_name VARCHAR(20) ,
grade INT(10)
);
2. by student Table and score Table add records
towards student The table inserts a record of INSERT The statement is as follows :
INSERT INTO student VALUES( 901,‘ Boss Zhang ’, ‘ male ’,1985,‘ Department of Computer Science ’, ‘ Haidian District, Beijing ’);
INSERT INTO student VALUES( 902,‘ Zhang Laoer ’, ‘ male ’,1986,‘ Department of Chinese ’, ‘ Changping District, Beijing ’);
INSERT INTO student VALUES( 903,‘ Zhang San ’, ‘ Woman ’,1990,‘ Department of Chinese ’, ‘ Yongzhou City, Hunan Province ’);
INSERT INTO student VALUES( 904,‘ Li Si ’, ‘ male ’,1990,‘ English department ’, ‘ Fuxin City, Liaoning Province ’);
INSERT INTO student VALUES( 905,‘ Wang Wu ’, ‘ Woman ’,1991,‘ English department ’, ‘ Xiamen City, Fujian Province ’);
INSERT INTO student VALUES( 906,‘ Wang Liu ’, ‘ male ’,1988,‘ Department of Computer Science ’, ‘ Hengyang City, Hunan Province ’);
towards score The table inserts a record of INSERT The statement is as follows :
INSERT INTO score VALUES(NULL,901, ‘ Computer ’,98);
INSERT INTO score VALUES(NULL,901, ‘ English ’, 80);
INSERT INTO score VALUES(NULL,902, ‘ Computer ’,65);
INSERT INTO score VALUES(NULL,902, ‘ chinese ’,88);
INSERT INTO score VALUES(NULL,903, ‘ chinese ’,95);
INSERT INTO score VALUES(NULL,904, ‘ Computer ’,70);
INSERT INTO score VALUES(NULL,904, ‘ English ’,92);
INSERT INTO score VALUES(NULL,905, ‘ English ’,94);
INSERT INTO score VALUES(NULL,906, ‘ Computer ’,90);
INSERT INTO score VALUES(NULL,906, ‘ English ’,85);
1. Inquire about student All the records of the table 
2. Inquire about student Table No 2 Strip to 4 Bar record 
3. from student Table to query the student numbers of all students (id)、 full name (name) And departments (department) Information about 
4. from student The information of students in computer department and English department can be found in the table 
5. from student Query in table 2010 Year age 18~22 Student information at age 
6. from student How many people are there in each department 
7. from score Query the highest score of each subject in the table 
8. Inquire about Li Si's Examination subjects (c_name) And test scores (grade)
9. Query all the students' information and exam information in the way of connection 
10. Calculate the total score of each student 
11. Calculate the average score of each test subject 
12. The computer score is lower than 95 Student information 
**13.** Search for information about students who take both computer and English exams 
14. Rank computer test scores from high to low 
15. from student Table and score The student number can be found in the table , Then merge the query results 
16. Check the names of students surnamed Zhang or Wang 、 Departments and examination subjects and results 
17. All the inquiries are the names of the students in Hunan 、 Age 、 Departments and examination subjects and results 
边栏推荐
- String容器的底层实现
- MySQL system variables and state variables
- Project | implement a high concurrency memory pool
- Shell
- [cloud native | learn kubernetes from scratch] VI. kubernetes core technology pod
- Web services (07) - LNMP one click deployment
- 22FTP
- DNS
- Web Service (04) -- Introduction and construction of lamp +discuz Forum
- mysql的安装
猜你喜欢
随机推荐
34iptables firewall
PXE实验
Deveco could not resolve com.huawei.ohos:hap:2.4.5.0. error
Shell(6)if判断
Shell (7) case statement
Harmonyos image processing application development live broadcast notes
shell课程总结
HarmonyOS图像处理应用开发实战直播笔记
21DNS域名解析
23NFS共享存储服务
SSH and NFS services
第一次使用c语言自己编写程序,有大佬可以稍微帮忙看看嘛
MySQL备份恢复
Small project - self connected campus network
Shell (12) regular expression
散户股票开户哪个证券公司好,哪个更安全
Typescript 14 starting from 0: built in tool type
Proxmox ve installation and initialization
【无标题】
Shell (13) Three Musketeers

![[untitled]](/img/2a/53327cd39db7871fa780ed599420d0.png)







