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. Redux Toolkit 的使用方法

    Redux Toolkit 是什么? Redux Toolkit 是 Redux 官方强烈推荐,开箱即用的一个高效的 Redux 开发工具集.它旨在成为标准的 Redux 逻辑开发模式,我们强烈建议你 ...

  2. 基于Python的OpenGL 01 之Hello Triangle

    1. 引言 本文基于Python语言,描述OpenGL的绘制流程,这里描述的是OpenGL的核心模式(Core-profile) 本文基于GLFW与PyOpenGL库进行开发,Python语言下的Op ...

  3. Angular ngx-translate中英文切换

    1.安装包 npm install @ngx-translate/core --save npm install @ngx-translate/http-loader --save 2.根模块app. ...

  4. Bouncy Castle密码算法库

    Bouncy Castle密码算法库 一.开发背景 Bouncy Castle 是一种用于 Java 平台的开放源码的轻量级密码术包.它支持大量的密码术算法,并提供 JCE 1.2.1 的实现.因为 ...

  5. 鉄道旅行 (Railroad Trip)

    题意 有 \(n\) 个城市, \(n-1\) 条道路.其中第 \(i\) 个城市和第 \(i+1\) 个城市由第 \(i\) 条道路连接.通过一条道路有两种付费方式:每次支付费用 \(a_i\) , ...

  6. windows自带xbox game bar如何更改录制视频保存位置

      若要更改保存游戏剪辑的位置,请使用文件资源管理器根据需要将"捕获"文件夹移动到电脑上的任意位置. Windows 会将游戏剪辑和屏幕截图保存在该文件夹中(无论移动到哪里).   ...

  7. SVG 从入门到后悔,怎么不早点学起来(图解版)

    点赞 + 关注 + 收藏 = 学会了 作为一只前端,只懂 Vue.React 感觉已经和大家拉不开距离了. 可视化.机器学习等领域 JS 都有涉及到,而可视化方面已经被很多领域用到,比如大屏项目. 可 ...

  8. 【微信公众号】记一次微信活动微信公众号分享没有LOGO的解决心路历程

    微信类的活动测过好几次了,以前的开发从来没有出过纰漏,这次也以为很简单.结果一个"分享后没有LOGO的问题",前端开发陆陆续续花了一周时间都不能解决,老是找后端和微信公众号配置问题 ...

  9. linux部署nacos集群

    linux部署nacos集群 一.简介: 什么是Nacos Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service的首字母简称,一个更易于 ...

  10. Python爬取网页上想要的数据

    1.源代码如下 from urllib.request import urlopen,Request import urllib.request import re from bs4 import B ...