关于查询的作业题
来源:互联网 发布:可以画画的软件 编辑:程序博客网 时间:2024/05/19 21:59
1.查询年龄比“刘晨”大的学生姓名
select sname
from student
where sage>
(select sage
from student
where sname = '刘晨'
)
2.参与选课的男生的姓名
select sname
from student
where sno in
(select student.sno
from sc,student
where sc.sno=student.sno and student.ssex='男'
);
3.没有参与选课的男生的学生姓名
select sname
from student
where sno not in
(select student.sno
from sc,student
where sc.sno=student.sno and student.ssex='男'
);
4.没有选修“1”号课程的学生姓名
select sname
from student
where sno not in
(select student.sno
from sc,student
where sc.sno=student.sno and sc.cno='1');
5.没有使用“P1”零件的工程名称
select jno,jname
from j
where jno not in
(select j.jno
from j,spj
where j.jno=spj.jno and pno='p1');
6.没有使用“S1”供应商零件的工程名称
select jno,jname
from j
where jno not in
(select j.jno
from spj,j
where j.jno=spj.jno and spj.sno='s1')
7.没有人选修的课程名称
select cname
from Course
where cname not in
(select cname
from Course,sc
where sc.cno=Course.cno)
使用EXISTS嵌套查询实现下列查询:
与“刘晨”不是一个系的学生
select *
from student
where sdept not in
(select sdept
from student
where sname='刘晨');
没有选择“1”号课的学生
select *
from student
where not exists
(select *
from sc
where sc.sno=student.sno and cno='1'
);
所有学生都没有选修的课程
select *
from course
where not exists
(select *
from sc
where course.cno=sc.cno );
查询‘1’号学生都没有选修的课程
select *
from course
where not exists
(select *
from sc
where course.cno=sc.cno and sno='200215121');
查询没有使用p1零件的工程名称
select *
from j
where not exists
(select *
from spj
where j.jno=spj.jno and pno='p1');
查询J1工程没有使用的零件名称
select *
from s
where not exists
(select *
from spj
where spj.sno=s.sno and jno='j1');
查询使用了红色零件的工程编号和名称
select *
from j
where exists
(select *
from spj,p
where spj.jno=j.jno and p.pno=spj.pno and p.color='红');
查询使用了天津供应商供应零件的工程编号和名称
select *
from j
where exists
(select *
from s,spj
where j.jno=spj.jno and s.sno=spj.sno and s.city='天津');
查询选修“数据库”课程学生的学号
select *
from sc
where exists
(select *
from course
where course.cno=sc.cno and course.cname='数据库');
查询选修“数据库”课程学生的姓名
select *
from student
where exists
(select *
from course,sc
where course.cno=sc.cno and student.sno=sc.sno and course.cname='数据库');
查询各学生学号、姓名和选课门数
查询各课程编号、名称和选课学生数
0 0
- 关于查询的作业题
- 一道关于SVM的机器学习作业题
- 关于微信红包的作业题的解决思路
- 一个计算机网络的作业题
- 我的作业题
- 小纪的作业题
- IO流的作业题
- 作业题
- 作业题
- 作业题
- 作业题
- 写一下我的第二篇博客吧,关于栈的,灵感来自一道作业题
- 分享一道伯克利 CS 61A 关于高阶函数的一道Python作业题(1)
- 分享一道伯克利 CS 61A 关于高阶函数的一道Python作业题(2)
- 分享一道伯克利 CS 61A 关于高阶函数的一道Python作业题(3)
- 一道Java的课后作业题
- 【GDKOI2014】小纪的作业题
- 今天留的作业题。自己写的。
- CSS常用布局之——一列定宽,一列自适应解决方案
- 用VS+Opencv3.1从双目立体视差图中重建三维点云
- C++异常捕捉两种情况-产生前-外层函数中
- Linux信号量sem_t简单实例运用
- Python项目使用memcached缓存
- 关于查询的作业题
- Flask进阶(一)——请求上下文和应用上下文完全解答(上)
- Medium:Find Bottom Left Tree Value
- 实现分页代码
- Java连接数据库步骤
- RNN简介
- 标签命名
- 关于使用bootstrap中modal和ajaxupload.js图片问题
- Arduino基础学习-tone函数