当前位置:网站首页>Day07 operation
Day07 operation
2022-07-27 17:05:00 【Ning Meng】
The first 1 topic :
1. Create table celebrity , works , summsry
create table celebrity(
sid int primary key,
sname varchar(50),
sage int,
ssex varchar(5)
)
create table works(
wid int primary key,
wwork varchar(50),
wdynasty varchar(20)
)
create table summary(
sid int,
wid int,
sassess varchar(255)
)2. Add data to the table
insert into celebrity values
(1,' Li Bai ',34,' male '),
(2,' Du Fu ',24,' male '),
(3,' Bai Juyi ',31,' male '),
(4,' Li shangyin ',40,' Woman '),
(5,' Su shi ',26,' male '),
(6,' Xin qiji ',22,' male ')
insert into works values
(1,' Drink in ',' Tang Dynasty '),
(2,' Intones difficult ',' Tang Dynasty '),
(3,' Rain in the night sent to the North ',' Tang Dynasty '),
(4,' In the Quiet Night ',' Tang Dynasty '),
(5,' Wang Yue ',' Tang Dynasty '),
(6,' Qiantang lake spring line ',' Tang Dynasty '),
(7,' Nostalgia for Chibi ',' Tang Dynasty '),
(8,' Shu Shui tunes ',' Tang Dynasty ')
insert into summary values
(1,1,' I'm born to be useful '),
(1,2,' The danger is high !'),
(6,8,' When is the moon '),
(3,6,' The flowers are getting more and more attractive '),
(4,3,' But when it rains at night '),
(5,7,' the mighty river flows eastward '),
(2,5,' The hills are small '),
(1,4,' look at the bright moon ')3.(1). Look up the author whose gender is male in the celebrity table
select sname from celebrity where ssex=' male ' 
(2) Query the author of Jingyesi
select celebrity.sname from summary inner join celebrity on summary.sid=celebrity.sid inner join works on summary.wid=works.wid where works.wwork=' In the Quiet Night '
(3) Inquire about the ages of Li Bai and Du Fu
select sname,sage from celebrity where sname in(' Li Bai ',' Du Fu ') 
(4) Check the number of men and women in the celebrity table
select count(*),ssex from celebrity group by ssex 
(5) Query the name of the work written by Bai Juyi and the corresponding famous sentences
select works.wwork,summary.sassess from summary inner join celebrity on summary.sid=celebrity.sid inner join works on summary.wid=works.wid where celebrity.sname=' Bai Juyi '
(6) The query age is 25 To 30 The number between the ages
select count(*) from celebrity where sage between 25 and 30 
(7) Query the two youngest data information in the celebrity list
select * from celebrity order by sage limit 0,2
(8) Query the name of Li Bai's work , Famous sentences and age
select works.wwork,summary.sassess,celebrity.sage from summary inner join celebrity on summary.sid=celebrity.sid inner join works on summary.wid=works.wid where celebrity.sname=' Li Bai '
(9) Change the Dynasty whose work is Wangyue to the Northern Song Dynasty
update works set wdynasty=' Northern song dynasty ' where wwork=' Wang Yue ' 
(10) Add an author Wang Wei in the celebrity list , Age 25, Gender male
insert into celebrity values(7,' Wang wei ',25,' male ')
The first 2 topic :
1. Create table product , user , orders
create table product(
pid int primary key,
pname varchar(50),
pprice int
)
create table user(
uid int primary key,
uname varchar(50),
uage int,
usex char(5)
)
create table orders(
opid int,
ouid int,
onumber int
)2. Add data
insert into product values
(1,' mobile phone ',2300),
(2,' The computer ',5600),
(3,' camera ',1200),
(4,' Projector ',2500)
insert into user values
(1,' Li San ',20,' male '),
(2,' Zhang Si ',23,' male '),
(3,' Zhao Wu ',25,' male '),
(4,' Sun Liu ',18,' Woman '),
(5,' The Monkey King ',24,' male ')
insert into orders values
(1,1,123123),
(1,2,112233),
(2,1,234567),
(2,5,787878),
(3,4,343421),
(3,5,909090),
(4,2,212112),
(4,1,343421)
3.(1) Query the user surnamed sun
select uname from user where uname like ' Grandchildren %'
(2) Query the oldest 2 Users
select uname from user order by uage desc limit 0,2
(3) Check the goods bought by Li San
select product.pname from orders inner join product on orders.opid=product.pid inner join user on orders.ouid=user.uid where user.uname=' Li San '
(4) Query the user name of the purchased computer
select user.uname from orders inner join product on orders.opid=product.pid inner join user on orders.ouid=user.uid where product.pname=' The computer '
(5) The query order is 909090 Corresponding user name and commodity name
select user.uname,product.pname from orders inner join product on orders.opid=product.pid inner join user on orders.ouid=user.uid where orders.onumber=909090
(6) Query the first two data of the highest price in the commodity table
select * from product order by pprice desc limit 0,2
The first 3 topic
1. Create a student information table S--student , Course selection information table SC--studentcourse , Course information sheet C--course
create table student(
sno int primary key,
sname varchar(50),
age int,
sex varchar(5)
)
create table course(
cno int primary key,
cname varchar(50),
cteacher varchar(50)
)
create table studentcourse(
sno int,
cno int,
scgrade int
)2. Add data
insert into student values
(1,' Zhang San ',18,' male '),
(2,' Li Si ',20,' Woman '),
(3,' Wang Wu ',23,' male '),
(4,' Zhao Liu ',22,' Woman ')
insert into course values
(1,'java',' He Hao '),
(2,'php',' Mei Jun Li '),
(3,'android',' Wang Chao ')
insert into studentcourse values
(1,1,50),
(2,1,66),
(3,1,90),
(1,2,55),
(2,2,68),
(3,2,61),
(4,2,44),
(1,3,90),
(2,3,78),
(3,3,22),
(4,3,55)3.(1) Inquire about SC The information in the table corresponds to the girls in the courses taught by Mr. He Hao
select * from studentcourse sc inner join student on sc.sno=student.sno
inner join course on sc.cno=course.cno where course.cteacher=' He Hao ' and student.sex=' Woman '
(2) Find out the information of all students who have not taken any teacher's courses
select * from studentcourse sc inner join student on sc.sno=student.sno
inner join course on sc.cno=course.cno where not course.cteacher=' He Hao '
(3) List courses that have failed ( The score is less than 60) Of students
select student.sname from studentcourse sc inner join student on sc.sno=student.sno
inner join course on sc.cno=course.cno where sc.scgrade<60 
The first 4 topic
1. Create student table student , The teacher table teacher
create table student(
id int primary key,
name varchar(20),
score int
)
create table teacher(
id int primary key,
name varchar(30),
class varchar(20),
classroom varchar(20),
student_id int
)2. Add data
insert into student values
(1,' Zhang San ',80),
(2,' Li Si ',56),
(3,' Wang Wu ',72),
(4,' Zhao Liu ',30),
(5,' Liu Qi ',66)
insert into teacher values
(1,' Liuliangyu ',' test ','2102A',1),
(2,' Liuliangyu ',' test ','2011A',2),
(3,' Fan Qingxiao ','android','2012A',3),
(4,' Sun Wenlong ','PHP','2101A',4),
(5,' Xu Tengsheng ','JAVA','2013B',5)3.(1) Inquire the names of the students and the corresponding subjects brought by teacher Liu Liangyu
select student.name,teacher.class from teacher inner join student on teacher.student_id=student.id where teacher.name=' Liuliangyu '
(2) Inquire about the students led by teacher Liu Liangyu , The name of the student who passed the grade
select student.name from teacher inner join student on teacher.student_id=student.id where teacher.name=' Liuliangyu ' and student.score>=60
(3) Query teacher Zhao Liu's teacher name and the corresponding subject name
select teacher.name,teacher.class from teacher inner join student on teacher.student_id=student.id where student.name=' Zhao Liu ' 
边栏推荐
- Automatic classification of e-commerce UGC pictures using Baidu PaddlePaddle easydl
- JSON data parsing
- js中的函数
- Unity 入门
- If you don't want to step on those holes in SaaS, you must first understand the "SaaS architecture"
- LOJ 576 - "libreoj noi round 2" sign in game [line segment tree]
- LNMP环境--部署wordpress
- Niuke topic -- binary search tree and bidirectional linked list
- 第7天总结&作业
- Jerry's maximum volume prompt sound cannot be broadcast [article]
猜你喜欢

选 择 结 构
![How to modify the decoding clock [chapter]](/img/a7/e55346a081fac0887b294b078a28a5.png)
How to modify the decoding clock [chapter]

Character function, string function and memory function of C language

Niuke topic -- symmetric binary tree

File类字节输入、输出流

Data collection: skillfully using Bloom filter to extract data summary

Flex flex flex box layout 2

UML diagram introduction

js中的函数

Dynamic memory allocation in C language
随机推荐
Share a scheme of "redis" to realize "chat round system" that can't be found on the Internet
JSP El expression, JSTL tag
C语言之分支循环语句
LOJ 576 - "libreoj noi round 2" sign in game [line segment tree]
Xcode 发布测试包TestFlight
JDBC连接数据库
CODIS cluster deployment
Automatic classification of e-commerce UGC pictures using Baidu PaddlePaddle easydl
Storage of data in C language
C语言之枚举和联合体
Flex弹性盒布局2
牛客题目——用两个栈实现队列、包含min函数的栈、有效括号序列
领导:谁再用redis过期监听实现关闭订单,立马滚蛋!
Interpretation of C basic syntax: summarize some commonly used but easily confused functions (i++ and ++i) in the program (bit field)
C语言之指针进阶
高精度定时器
Servlet用Cookie实现用户上次登录时间
字符流读取文件
Shardingsphere-proxy-5.0.0 distributed snowflake ID generation (III)
Servlet中文乱码setContentType设置无效