博客
关于我
数据库SQL查询作业
阅读量:130 次
发布时间:2019-02-27

本文共 1178 字,大约阅读时间需要 3 分钟。

 

--设有三个关系--S(S#,SNAME,AGE,SEX)--SC(S#,C#,GRADE)--C(C#,CNAME,TEACHER)--(1)检索LIU老师所授课程的课程号、课程名select c#,cname from cwhere teacher='LIU'--(2)检索年龄大于23岁的男同学的学号和姓名select s#,sname from swhere age>23 and sex='男'--(3)检索学号为S3学生所学课程的课程名与任课教师名select cname,teacher from c,scwhere c.c#=sc.c# and s#='s3'--(4)检索至少选修LIU老师所授课程中一门课程的女学生的姓名--1.嵌套查询select sname from swhere sex='女' and s# in(select s# from sc where c# in(select c# from c where teacher='LIU'))--2.多表联合查询select sname from s,sc,c where s.s#=sc.s# and sc.c#=c.c# and teacher='LIU' and s.sex='女'--(5)检索王同学不学的课程号--1.select c# from c where c# not in(select c# from sc where s# in (select s# from s where sname='wang'))--2.select c# from sc where c# not in(select c# from s,sc where s.s#=sc.s# and sname='wang') --(6)检索至少选修两门课程的学生学号select distinct x.s# from sc x,sc ywhere x.s#=y.s# and x.c#!=y.c#--(7)检索全部学生都选修的课程的课程号与课程名--1.select c.c#,cnamefrom sc,cwhere sc.c#=c.c#group by c.c#,cname having COUNT(*)=(select COUNT(*)from s)--2.select c#,cname from cwhere not exists(select * from swhere s# not in(select * from sc where sc.c#=c.c#));--(8)检索选修课程包含LIU老师所授课程的学生学号select distinct s# from scwhere c# in(select c# from cwhere teacher='liu');

 

转载地址:http://igdb.baihongyu.com/

你可能感兴趣的文章
mysql 1593_Linux高可用(HA)之MySQL主从复制中出现1593错误码的低级错误
查看>>
mysql 5.6 修改端口_mysql5.6.24怎么修改端口号
查看>>
mui折叠面板点击事件跳转
查看>>
MySQL 8 公用表表达式(CTE)—— WITH关键字深入用法
查看>>
mysql 8 远程方位_mysql 8 远程连接注意事项
查看>>
MUI框架里的ajax的三种方法
查看>>
MySQL 8.0 恢复孤立文件每表ibd文件
查看>>
Mysql 8.0 新特性
查看>>
MultCloud – 支持数据互传的网盘管理
查看>>
MySQL 8.0.23中复制架构从节点自动故障转移
查看>>
MySQL 8.0开始Group by不再排序
查看>>
mysql ansi nulls_SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 什么意思
查看>>
multi swiper bug solution
查看>>
MySQL Binlog 日志监听与 Spring 集成实战
查看>>
MySQL binlog三种模式
查看>>
multi-angle cosine and sines
查看>>
Mysql Can't connect to MySQL server
查看>>
mysql case when 乱码_Mysql CASE WHEN 用法
查看>>
Multicast1
查看>>
mysql client library_MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法...
查看>>