当前位置:网站首页>MySQL single table query exercise
MySQL single table query exercise
2022-07-27 01:53:00 【Palm nine】
material :
/*
SQLyog Ultimate v8.32
MySQL - 5.7.14 : Database - db
*/
/*!40101 SET NAMES utf8 */;
/!40101 SET SQL_MODE=‘’/;
/!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 /;
/!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 /;
/!40101 SET @[email protected]@SQL_MODE, SQL_MODE=‘NO_AUTO_VALUE_ON_ZERO’ /;
/!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 /;
CREATE DATABASE /!32312 IF NOT EXISTS/db /*!40100 DEFAULT CHARACTER SET utf8 */;
USE db;
/*Table structure for table course */
DROP TABLE IF EXISTS course;
CREATE TABLE course (
cs_id int(11) NOT NULL COMMENT ‘ Course number ’,
cs_name varchar(50) NOT NULL COMMENT ‘ Course name ’,
cs_credit tinyint(255) unsigned DEFAULT NULL COMMENT ‘ course credit ’,
cs_type char(12) DEFAULT NULL COMMENT ‘ Course category ’,
cs_depart char(6) DEFAULT NULL COMMENT ‘ The name of the Department ’,
PRIMARY KEY (cs_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table course */
insert into course
(cs_id,cs_name,cs_credit,cs_type,cs_depart) values
(5200313,‘ Database principle and Application ’,4,‘ Core specialty ’,‘ Information industry ’),
(5203314,‘ Introduction to computer ’,4,‘ General Education ’,‘ Information industry ’),
(5219314,‘ data structure ’,5,‘ Professional core ’,‘ Information industry ’),
(5223013,‘ College Physics ’,4,‘ Professional basis ’,‘ Information industry ’),
(5227614,‘ Graduation practice ’,4,‘ Focus on practice ’,‘ Information industry ’),
(5230912,‘ Cloud computing ’,2,‘ Co electives ’,‘ Information industry ’),
(5236212,‘ machine learning ’,2,‘ Co electives ’,‘ Information industry ’),
(5237514,‘c Language ’,4,‘ Professional basis ’,‘ Information industry ’),
(5245112,‘ Blockchain ’,2,‘ Take any elective course ’,‘ Information industry ’),
(7200422,‘ Intellectual property law ’,2,‘ Take any elective course ’,‘ Grammar ’),
(20201833,‘ probability theory ’,3,‘ Professional basis ’,‘ Basics ’),
(20202336,‘ Advanced mathematics ’,6,‘ Professional basis ’,‘ Basics ’),
(29299131,‘ Labor Education ’,1,‘ Focus on practice ’,‘ Academic Affairs ’);
/*Table structure for table student */
DROP TABLE IF EXISTS student;
CREATE TABLE student (
stu_id bigint(11) unsigned NOT NULL COMMENT ‘ Student number ’,
stu_name char(12) NOT NULL COMMENT ‘ full name ’,
stu_sex enum(‘ male ’,‘ Woman ’) DEFAULT NULL COMMENT ‘ Gender ’,
stu_age tinyint(255) unsigned DEFAULT NULL COMMENT ‘ Age ’,
stu_major char(9) DEFAULT NULL COMMENT ‘ major ’,
stu_college char(12) DEFAULT NULL COMMENT ‘ college ’,
PRIMARY KEY (stu_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Data for the table student */
insert into student(stu_id,stu_name,stu_sex,stu_age,stu_major,stu_college) values
(201804550101,‘ Kui Guo ’,‘ male ’,22,‘ Family planning ’,‘ Institute of information technology ’),
(201804550102,‘ LV Yuhang ’,‘ male ’,18,‘ Family planning ’,‘ Institute of information technology ’),
(201804550103,‘ Zhang Haohui ’,‘ Woman ’,19,‘ Family planning ’,‘ Institute of information technology ’),
(201804550107,‘ Ding Zhijie ’,‘ male ’,17,‘ Finance ’,‘ Gold Trade College ’),
(201804550109,‘ Fan Wei ’,‘ male ’,19,‘ Finance ’,‘ Gold Trade College ’),
(201804550116,‘ Zhang Yiting ’,‘ Woman ’,17,‘ big data ’,‘ Institute of information technology ’),
(201804550120,‘ Zhang Wei ’,‘ male ’,19,‘ Family planning ’,‘ Institute of information technology ’),
(201804550121,‘ Zhu Liuyang ’,‘ Woman ’,20,‘ Family planning ’,‘ Institute of information technology ’),
(201804550144,‘ Tan Bingyan ’,‘ male ’,20,‘ big data ’,‘ Institute of information technology ’),
(201804550153,‘ Yang Zhiqiang ’,‘ male ’,17,‘ big data ’,‘ Institute of information technology ’);
/*!40101 SET [email protected]_SQL_MODE /;
/!40014 SET [email protected]_FOREIGN_KEY_CHECKS /;
/!40014 SET [email protected]_UNIQUE_CHECKS /;
/!40111 SET [email protected]_SQL_NOTES */;
Mission :
1. Query the information of all courses .
2. Inquire about the course name offered by the Institute of information technology 、 Course number and credits .
3. Query credits exceed 3 Course code for credits 、 Course name and starting unit .
4. Query the information of students majoring in accounting and big data .
5. Query the name and student number of students who are not Information Technology College .
6. The age of inquiry is 17,18,19 Student's name and major .

7. Check the credits in 2 To 4 Information between courses .
8. Query the course name with “ data ” Course name 、 Course number and starting unit .
9. What are the specialties of information technology college .
10. Query student information with empty age .
11. Query the unit and course name of the centralized practice course offered by the Institute of information technology .
12. Inquire about the types of courses offered by the Institute of information technology .
13. Query the number of majors of students .
14. Check the average credits of courses offered by the Institute of information technology .
15. Query student information , Query results are sorted by name in ascending order .
16. Inquire about The maximum age of students in each major 、 Minimum and average age , The query results are arranged in descending order of average age .
17. Query the number of courses offered by each course unit , The direct inquiry results are arranged in ascending order according to the number of courses .
18. The number of courses offered by the query unit is less than 2 The opening unit and course name of the course .
边栏推荐
猜你喜欢
随机推荐
Shell loop statement
构造函数,拷贝函数和析构函数的区别
25PXE高效批量网络装机
Shell
mysql的安装
网络与VPC之动手实验
24SSH服务
Shell(8)循环
SSH和NFS服务
[cann training camp] enter media data processing (Part 2)
使用ECS和OSS搭建个人网盘
识别神器Mx-yolov3
RT-thread学习
数字图像处理重点总结复习
Shell
String容器的底层实现
Identify artifact MX yolov3
DNS
39安装 LNMP
C language automatically generates code comments: korofileheader plug-in

![[polymorphism] the detailed introduction of polymorphism is simple and easy to understand](/img/85/7d00a0d9bd35d50635a0e41f49c691.png)







