SQL之查询语句的实践运用
来源:互联网 发布:mysql 添加字符串 编辑:程序博客网 时间:2024/06/03 20:39
第一次数据库系统上机作业
1、
mysql> select sno,grade
-> from sc
-> where cno="CS3121014";
2、
mysql> select sc.sno,sname
-> from sc,student
-> where student.sno=sc.sno and
-> sc.cno="CS3121014";
3、
mysql> select student.sno,sname,grade
-> from student,sc,course
-> where course.cno=sc.cno and
-> student.sno=sc.sno and
-> cname="数据库系统"
-> order by grade desc;
4、
mysql> select distinct sno
-> from sc
-> where cno in ("CS3121014","CS3221018");
5、
mysql> select sno
-> from sc
-> where cno="CS3121014" and sno in
-> (select sno
-> from sc
-> where cno="CS3221018");
6、
mysql> select sno
-> from sc
-> where not exists
-> (select sno
-> from sc
-> where cno="CS3121014");
7、
mysql> select cpno
-> from pcourse
-> where cno="CS3121014";
8、***有难度
mysql> select sno
-> from student
-> where not exists
-> (select *
-> from course
-> where not exists
-> (select *
-> from sc
-> where sno=student.sno
-> and cno=course.cno));
9、***
mysql> select distinct sno
-> from sc scx
-> where not exists
-> (select *
-> from sc scy
-> where scy.sno="03051066" and
-> not exists
-> (select *
-> from sc scz
-> where scz.sno=scx.sno and
-> scz.cno=scy.cno));
10、
mysql> select sname,sno,ssex
-> from student
-> where sname like "刘%";
11、
mysql> select sname,sno
-> from student
-> where sname like "_阳%";
12、
mysql> select count(distinct sno)
-> from sc;
13、
mysql> select max(grade)
-> from sc
-> where cno="CS3121014";
14、
mysql> select sum(ccredit)
-> from sc,course
-> where sc.cno=course.cno and
-> sc.sno="03051014";
15、
mysql> select sno
-> from sc
-> group by sno
-> having count(*)>3;
16、
mysql> select sno,count(*)
-> from sc
-> where grade>92
-> group by sno
-> having count(*)>4;
以上估计有很多错误的地方,等到时候和同学对一下答案再来改一下。
- SQL之查询语句的实践运用
- sql基础查询语句运用
- SQL基础之语句的编写实践
- SQL语句之查询
- SQLite数据库的使用之运用SQL语句
- MySQL常见的查询语句的运用
- SQL简单实践之sql语句
- Sql语句之高级查询
- Sql语句之select查询
- SQLSERVER2008R2之SQL查询语句
- SQL语法之查询语句
- oracle之SQL语句查询
- SQL语句之高级查询
- SQL case 语句的实践
- SQL语句之简单查询语句
- SQL语句之SELECT查询语句
- SQL 中树形结构查询的运用
- SQL Server 子查询的运用
- Microsoft Word 2010
- package.json.lock 文件
- 伪共享,并发编程无声的性能杀手
- Android 屏幕适配总结
- linux常用指令
- SQL之查询语句的实践运用
- PHP fileperms()、filesize()和stat()函数
- Linux vmstat命令实战详解
- 阿里云服务器下安装ftp
- JAVASE之Set和Map
- hive-2.3.2配置步骤及问题解答
- python学习笔记7:对象引用与对象
- 单例模式--实现多文档窗口(MDI)
- 文件下载代码(十一)