• 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 的化学成绩。



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

  • 相关阅读:
    Mozilla Prism v0.9 For Windows/Linux/Mac
    Firefox 3.0十大年夜新特征(1)
    刊行版:Epidemic GNU/Linux 2.1发布
    斥地版:Red Hat Enterprise Linux 4.7 Beta公布公布
    linux下安装drcom1.3.7心得
    Oracle老手艺对Linux意味着什么?
    学Linux要火山式的驾御还是垂垂来
    Firefox 3.0 RC2本周颁发
    net命令详解 **net accounts /maxpwage:unlimited
    学习官方示例 TApplication.OnDeactivate
  • 原文地址:https://www.cnblogs.com/MrQlyn/p/10236352.html
Copyright © 2020-2023  润新知