navicat
-创建
-新建查询
-转储sql文件
命令:
转储当前目录所有的文件与数据:mysqldump -u root db4 > db4.sql -p
转储当前目录到表结构没有数据:mysqldump -u root -d db4 > db4.sql -p
导入文件:mysqldump -u root -d db4 < db4.sql -p
执行导入文件之前一定要有数据库:
create dabatase db5;
mysqldump -u root -d db5 < db1.sql -p;
注释语句有空格:-- select * from score where number>=60;

练习:
-- select * from score where number>=60;
-- select * from course group by tearch_id;
-- 每个老师教了几门课进行统计:
-- select tearch_id,count(cname) from course group by tearch_id;
-- 显示课程表的所有字段名称,并且要显示老师姓名,需要连表查询:
-- select * from course
-- LEFT JOIN teacher on course.tearch_id=teacher.tid;

-- 显示学生的所有字段,并要显示班级,需要连表查询:
--select *from student
--left join class on student.class_id=class.uid;

-- 显示性别字段,并要统计男女的个数,需要连表查询:
-- 1.select * from student
-- 2.select * from student group by gender
-- 3.select gender,count(gender) from student group by gender
select gender,count(gender) from student group by gender;
-- 这么写也可以
select gender,count(sid) from student group by gender;

第二段:

临时表创建:
select sid from (select * from score where number > 60) as B;

这么写就报错,因为临时表中没有sid字段。必须用as B才会临时表。
select sid from (select num,course from score where number > 60) as B;

select * from score;
select student_id from score group by student_id;
select student_id,avg(number)from score group by student_id;
select student_id,avg(number)from score group by student_id having avg(number)>60;
select * from (select student_id,avg(number)from score group by student_id having avg(number)>60) as B;

select * from (select student_id,avg(number)from score group by student_id having avg(number)>60) as B
left join student on B.student_id = student.sid;

select student_id,sname from (select student_id,avg(number)from score group by student_id having avg(number)>60) as B
left join student on B.student_id = student.sid;

select B.student_id,student.sname,ccc from (select student_id,avg(number) as ccc from score group by student_id having avg(number)>60) as B
left join student on B.student_id = student.sid;

select * from score left join student on score.student_id=student.sid;
select score.student_id,student.sname from score left join student on score.student_id=student.sid;

select sid,1 from tb;显示sid的同时,多加一列为1

select score.student_id,student.sname,count(student_id),sum(number) from score left join student on score.student_id=student.sid group by score.student_id;

没学过老师的课程:
select * from course left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空";

select teacher.tid from course left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空";

select * from score where course_id not in (2,4);

select * from score where course_id not in (select teacher.tid from course left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空")

select * from score where course_id not in (select teacher.tid from course left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空")
group by student_id;

select * from (select score.student_id as bid from score where course_id not in (select teacher.tid from course left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空") ) as B
left join student on B.bid=student.sid;

选过的老师ID
select * from score where course_id in (select teacher.tid from course left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空")

6.没有选过老师的学生的信息
select * from student where sid not in (select student_id from score where course_id in (select course.cid from course
left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空")
group by student_id)

select student.sid,student.sname from student where sid not in (select student_id from score where course_id in (select course.cid from course
left join teacher on course.tearch_id=teacher.tid where teacher.tname="空空")
group by student_id)

2.物理>物理的成绩选取
select * from score
left join course on score.course_id=course.cid;

select * from score
left join course on score.course_id=course.cid where course.cname="生物";

字段筛选:
select score.sid,score.student_id,course.cname,score.number from score
left join course on score.course_id=course.cid where course.cname="生物";

select score.sid,score.student_id,course.cname,score.number from score
left join course on score.course_id=course.cid where course.cname="物理";

两列数据中,同行进行比较
select * from tb1 id1>id2

将生物列出来的表,与物理成绩列出的信息,联成一张表,进行一个学生的成绩进行比较
select * from
(select score.sid,score.student_id,course.cname,score.number from score
left join course on score.course_id=course.cid where course.cname="生物") as A
inner join
(select score.sid,score.student_id,course.cname,score.number from score
left join course on score.course_id=course.cid where course.cname="物理") as B
on A.student_id=B.student_id
where A.number>B.number;

二.navicate的更多相关文章

  1. Python全栈开发之MySQL(二)------navicate和python操作MySQL

    一:Navicate的安装 1.什么是navicate? Navicat是一套快速.可靠并价格相宜的数据库管理工具,专为简化数据库的管理及降低系统管理成本而设.它的设计符合数据库管理员.开发人员及中小 ...

  2. Navicate 连接阿里云MySQL(两种方式及原理讲解)

    Navicate 连接阿里云(两种方式及原理讲解) 一.直连方式(通过3306端口) 1.概述 2. 环境准备 3.操作及讲解 二.使用SSH通道 1.概述 2.环境准备 3.操作及讲解 如果对你有帮 ...

  3. 【小程序分享篇 二 】web在线踢人小程序,维持用户只能在一个台电脑持登录状态

    最近离职了, 突然记起来还一个小功能没做, 想想也挺简单,留下代码和思路给同事做个参考. 换工作心里挺忐忑, 对未来也充满了憧憬与担忧.(虽然已是老人, 换了N次工作了,但每次心里都和忐忑). 写写代 ...

  4. 前端开发中SEO的十二条总结

    一. 合理使用title, description, keywords二. 合理使用h1 - h6, h1标签的权重很高, 注意使用频率三. 列表代码使用ul, 重要文字使用strong标签四. 图片 ...

  5. 【疯狂造轮子-iOS】JSON转Model系列之二

    [疯狂造轮子-iOS]JSON转Model系列之二 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇<[疯狂造轮子-iOS]JSON转Model系列之一> ...

  6. 【原】Android热更新开源项目Tinker源码解析系列之二:资源文件热更新

    上一篇文章介绍了Dex文件的热更新流程,本文将会分析Tinker中对资源文件的热更新流程. 同Dex,资源文件的热更新同样包括三个部分:资源补丁生成,资源补丁合成及资源补丁加载. 本系列将从以下三个方 ...

  7. 谈谈一些有趣的CSS题目(十二)-- 你该知道的字体 font-family

    开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...

  8. MIP改造常见问题二十问

    在MIP推出后,我们收到了很多站长的疑问和顾虑.我们将所有疑问和顾虑归纳为以下二十个问题,希望对大家理解 MIP 有帮助. 1.MIP 化后对其他搜索引擎抓取收录以及 SEO 的影响如何? 答:在原页 ...

  9. 如何一步一步用DDD设计一个电商网站(二)—— 项目架构

    阅读目录 前言 六边形架构 终于开始建项目了 DDD中的3个臭皮匠 CQRS(Command Query Responsibility Segregation) 结语 一.前言 上一篇我们讲了DDD的 ...

  10. ASP.NET Core 之 Identity 入门(二)

    前言 在 上篇文章 中讲了关于 Identity 需要了解的单词以及相对应的几个知识点,并且知道了Identity处在整个登入流程中的位置,本篇主要是在 .NET 整个认证系统中比较重要的一个环节,就 ...

随机推荐

  1. JSP 页面引入静态资源 404 未找到

    jsp 页面引入了 css 文件,部署项目时发现 css 不生效,打开 f12 查看网络,发现请求状态码是 404.导致这个问题的情况大概有以下两种情况: 如果你通过浏览器 f12 查看 link 或 ...

  2. OpenLayers结合JSTS实现空间运算

    1. 引言 空间运算利用几何函数来接收输入的空间数据,对其进行分析,然后生成输出数据,输出数据为针对输入数据执行分析的派生结果. 可从空间运算中获得的派生数据包括: 作为输入要素周围缓冲区的面 作为对 ...

  3. Linux route命令修改默认路由优先级

    (自测可用)摘自:https://www.cnblogs.com/luoyang712/p/11953256.html 在多个网络连接的情况下,比如以太网和WIFI同时存在的时候,路由表中就会存在多个 ...

  4. 如何用HP 39GS计算器画出双曲线图像

    1.双曲线标准方程和参数方程 2.计算器上的操作 1.打开APLET->Parametric->START 2.设置X1(T)=3/COS(T),X2(T)=4*TAN(T) 3.SHIF ...

  5. [后端-Flask总结]-flask学习总结

    1.flask开发基础与入门: 1.1web开发基础 1.1.1 前端框架: bootstrap, j-query, angular, react 1.2 flask 路由 from flask im ...

  6. N63050 第二周运维作业

    1.显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录 1 [root@centos8 etc]#touch 5a.txt 9a.txt 2 [root@cento ...

  7. el-dialog 遮罩层覆盖内容的问题

    页面组件层级太多,就会出现遮罩层覆盖dialog里面内容的问题 解决:  :append-to-body="true" 把遮罩层添加到body上面    用z-index 设置没效 ...

  8. 新的学习历程-python2 print

    1 print('hello world!') 2 print('hello','world!') #逗号自动添加默认的分隔符:空格 3 print('hello'+'world!') #加号表示字符 ...

  9. FileChannel 数据传输(文件拷贝)

    import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import ...

  10. OI常见缩写

    AC = Apareciym 显形咒 CE = Crucio 钻心咒 PE = Petrificus 石化咒 RE = Reducto 粉碎咒 WA = Wingardium Leviosa 悬浮咒 ...