当前位置:网站首页>Database Experiment 3: data query
Database Experiment 3: data query
2022-06-12 05:47:00 【LEO-max】
Experiment three Data query experiment guidance
( Simple queries and complex queries )
1. The experiment purpose
(1) Yes, experiment 1 、 Experiment 2 has been built student 、course 、sc Query table .
(2) Fully experience SQL Structured query function of language , Let students fully understand SQL The flexibility of language , Powerful .
2. Experimental content
(1) Based on Experiment 1 and Experiment 2 , Query the database , Fully experience SQL The power of language . Simple query : Simple single table query with selection and projection .、 contain between、is null Single table query with equal conditions . Single table query with grouping and sorting 、 Simple multi table query with join conditions .
(2) nested queries : Use In Nested query of phrases 、 Use Exists Nested query of phrases 、 Multi table query using set operation .
3. The experimental requirements
(1) Check the student number and name of all students .
SELECT sno,sname FROM student;
(2) Check the detailed records of all students .
SELECT * FROM student;
(3) Check all students' names and year of birth .
SELECT sname,sage FROM student;
(4) Query the student number of the students who have taken the course .
SELECT sno from sc;
(5) Check the names of students in the computer department .
SELECT sname from student where sdept=' Department of accounting ';
(6) The age of inquiry is 20 Student number and age of computer students under years old .
SELECT sno,sage from student where sdept=' Department of accounting ' AND sage<20;
(7) The age of inquiry is 20—22 The student number of a 12-year-old student .
SELECT sno FROM student WHERE sage BETWEEN 20 AND 22;
(8) Query information system 、 Information for students of computer department and foreign language department .
SELECT * FROM student WHERE sdept IN(' Department of accounting ',' Department of telecommunications ',' Department of foreign languages ');
(9) Check the last name “ Wu ” Information about our students .
SELECT * FROM student where sname LIKE ' Wu %';
(10) Check the elective course 3 Student number and grades of students in course No , The results are arranged in descending order of scores .
SELECT sno,grade FROM sc WHERE cno='3' ORDER BY grade DESC;
(11) Check the total number of students .
SELECT COUNT(*) FROM student;
(12) Check options 1 The highest score of students in course No .
SELECT MAX(grade) FROM sc where cno='1';
(13) Check the elective course 3 Student number of students with more than courses .
SELECT sno FROM sc HAVING COUNT(sno) > 3;
(14) Inquire about each student and their elective courses .
SELECT
student.sno,
sname,
course.cno,
course.cname,
grade
FROM
student,
course,
sc
WHERE
student.sno = sc.sno
AND sc.cno = course.cno;
(15) Check options 2 Course No. and the score is 90 All students with scores above .
SELECT
student.sno,
sname,
grade,
cno
FROM
student,
sc
WHERE
student.sno = sc.sno
AND cno='2'
AND grade>90;
(16) Check the student number of each student 、 full name 、 Course name and grade .
SELECT
student.sno,
sname,
cno,
grade
FROM
student,
sc
WHERE
student.sno = sc.sno;
(17) Query and “ Zhang San ” Students in the same department .
SELECT
sno,
sname,
sdept
FROM
student
WHERE
sdept = (
SELECT
sdept
FROM
student
WHERE
sname = ' Qi Junbao '
);
(18) Query the elective course named “ database ” Student ID and name of .
SELECT
student.sno,
sname
FROM
student,
course,
sc
WHERE
student.sno = sc.sno
AND course.cno = sc.cno
AND course.cname = ' database ';
(19) There is no elective course 1 The name of the student in course No .
SELECT
sname
FROM
student
WHERE
NOT EXISTS (
SELECT
*
FROM
sc
WHERE
student.sno = sc.sno
AND sc.cno = '1'
);
(20) Query the names of students who have taken all courses .
SELECT
sname
FROM
student
WHERE
NOT EXISTS (
SELECT
*
FROM
course
WHERE
NOT EXISTS (
SELECT
*
FROM
sc
WHERE
student.sno = sc.sno
AND sc.cno = course.cno
)
);
Ask to write all the code of Experiment 3 ,
Be careful :
1. All the code
2. The full width of the code
3. Regular format , Easy to read
边栏推荐
猜你喜欢

38. appearance series

RTMP streaming +rtmp playback low delay solution in unity environment

Why should state-owned enterprises go public

Introduction to thread pool: ThreadPoolExecutor

Chapter 8 - structure

Individual application for ov type SSL certificate

How Wireshark decrypts WiFi data packets

March 22, 2021

Introduction to sringmvc

16. sum of the nearest three numbers
随机推荐
Detailed explanation of WiFi 802.1x authentication process
SIM卡信号的驱动电流是多少mA,是否是可调节的?
The relation between virtual function and pure virtual function
AddUser add user and mount hard disk
Chapter 8 - structure
什么是工程预付款
arp timer and arptables
beginning一款非常优秀的emlog主题v3.1,支持Emlog Pro
China's elastic belt market trend report, technical dynamic innovation and market forecast
[JS knowledge] easily understand JS anti shake and throttling
merge sort
XML parameter schema, the same MTK SW version is compatible with two different sets of audio parameters
What is the lszrz protocol used at ordinary times? Talk about xmodem/ymodem/zmodem
Towards End-to-End Lane Detection: an Instance SegmentationApproach
Recursive implementation of exponential, permutation and combination enumerations
C WMI query remote Win32_ Operatingsystem class
DMA RDMA technology details
登录验证过滤器
Win10 desktop unlimited refresh
将一个文件夹图片分成训练集和测试集