MySQL作业

题目一:使用连接查询的方式,查询出各员工所在部门的人数与工程数,工程数命名为count_project。(连接3个表,并使用COUNT内置函数)

 

Create table employee(

Id int(3)primary key,

Name varchar(20),

Age int(1)

);

Create table department(

Rearch int(3),

Constraint foreign key(Rearch) references employee(id),

Sale int(3),

Constraint foreign key(Sale) references employee(id)

);

Create table project(

pid int(3),

Constraint foreign key(pid) references employee(id),

Number int(1)default 0

);

Empoyee

Id(primary key)

Name

age

001

Tom

25

002

Jack

18

003

Lucy

33

111

Marry

15

110

James

21

Department

Rearch(foreign key)

Sale(foreign key)

001

111

002

110

003

 

Project

PId(foreign key)

001

002

003

111

110

number(default 0)

2

3

1

0

5

insert into project(pid,number)values(001,2),(002,3),(003,1),(111,0),(110,5);

只能分俩步完成

第一步:select id,name,age,count(rearch),numberfrom employee,department,project where id in(select rearch from departmentwhere rearch=employee.id ) and id in(pid) group by id;

第二步:select id,name,age,count(sale),numberfrom employee,department,project where id in(select sale from department wheresale=employee.id ) and id in(pid) group by id


题目二:

在挑战实验1中构建的成绩管理系统中,物理老师想要找出分数最高的同学进行表扬,请你找出这个同学并把他的信息(id、姓名、性别)输出到路径 E盘 下的physics.txt文件中。同时 Tom 的化学成绩有异议,需要在原来的基础上加3分,请更新 Tom 的化学成绩。



导入导出操作在可视化软件进行

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值