当前位置: 首页 > news >正文

网站建设的关键技术网络热词2022流行语及解释

网站建设的关键技术,网络热词2022流行语及解释,学校网站建设内容,企业文化怎么写文章目录 MySQL系列:1.内连接2.外连接3.自连接4.子查询5.合并查询6.插入查询 MySQL系列: 初识MySQL,MySQL常用数据类型和表的操作,增删改查(CRUD)操作(总),数据库约束数据库设计 #班级表 drop table if exists class; create ta…

文章目录

    • MySQL系列:
    • 1.内连接
    • 2.外连接
    • 3.自连接
    • 4.子查询
    • 5.合并查询
    • 6.插入查询

MySQL系列:

初识MySQL,MySQL常用数据类型和表的操作,增删改查(CRUD)操作(总),数据库约束数据库设计

#班级表
drop table if exists class;
create table class(
id bigint primary key auto_increment,
name varchar(20)
);
#学生,课程与成绩的多对多关系
drop table if exists student;
create table student(
id bigint primary key auto_increment,
name varchar(20)not null,
sno varchar(10) not null,
age int default 18,
gender tinyint(1),
enroll_date date,
class_id bigint,
foreign key(class_id) references class(id)
);
#课程表
drop table if exists course;
create table course(
id bigint primary key auto_increment,
name varchar(20)
);
#成绩表
drop table if exists score;
create table score(
id bigint primary key auto_increment,
score float,
student_id bigint,
course_id bigint,
foreign key (student_id) references student(id),
foreign key (course_id) references course(id)
);# 课程表
insert into course (name) values ('Java'), ('C++'), ('MySQL'), ('操作系统'), ('计算机网络'), ('数据结构');
# 班级表
insert into class(name) values ('Java001班'), ('C++001班'), ('前端001班');
# 学生表
insert into student (name, sno, age, gender, enroll_date, class_id) values 
('唐三藏', '100001', 18, 1, '1986-09-01', 1),
('孙悟空', '100002', 18, 1, '1986-09-01', 1),
('猪悟能', '100003', 18, 1, '1986-09-01', 1),
('沙悟净', '100004', 18, 1, '1986-09-01', 1),
('宋江', '200001', 18, 1, '2000-09-01', 2),
('武松', '200002', 18, 1, '2000-09-01', 2),
('李逹', '200003', 18, 1, '2000-09-01', 2),
('不想毕业', '200004', 18, 1, '2000-09-01', 2);# 成绩表
insert into score (score, student_id, course_id) values
(70.5, 1, 1),(98.5, 1, 3),(33, 1, 5),(98, 1, 6),
(60, 2, 1),(59.5, 2, 5),
(33, 3, 1),(68, 3, 3),(99, 3, 5),
(67, 4, 1),(23, 4, 3),(56, 4, 5),(72, 4, 6),
(81, 5, 1),(37, 5, 5),
(56, 6, 2),(43, 6, 4),(79, 6, 6),
(80, 7, 2),(92, 7, 6);

在这里插入图片描述

在这里插入图片描述

1.内连接

语法:
1 select 字段 from 表1 别名1, 表2 别名2 where 连接条件 and 其他条件;
2 select 字段 from 表1 别名1 [inner] join 表2 别名2 on 连接条件 where 其他条件;

查询所有学生的考试成绩:

select s.name,c.name 课程,sc.score 分数 from score sc,student s,course cwhere c.id=sc.course_idand s.id=sc.student_id;

在这里插入图片描述

select s.name,c.name as course,sc.score 
from student s
join score sc on s.id=sc.student_id
join course c on sc.course_id=c.id;

在这里插入图片描述

2.外连接

外连接分为左外连接、右外连接和全外连接三种类型,MySQL不⽀持全外连接。
• 左外连接:返回左表的所有记录和右表中匹配的记录。如果右表中没有匹配的记录,则结果集中对
应字段会显⽰为NULL。
• 右外连接:与左外连接相反,返回右表的所有记录和左表中匹配的记录。如果左表中没有匹配的记
录,则结果集中对应字段会显⽰为NULL。
• 全外连接:结合了左外连接和右外连接的特点,返回左右表中的所有记录。如果某⼀边表中没有匹
配的记录,则结果集中对应字段会显⽰为NULL。

SELECT c.name AS course,COUNT(sc.student_id) AS student_count
FROM score sc
RIGHT JOIN course c ON sc.course_id=c.id
GROUP BY c.name;SELECT s.name,COUNT(sc.course_id) AS course_count
FROM student s
LEFT JOIN score sc ON s.id=sc.student_id
GROUP BY s.name;

在这里插入图片描述

左外连接:

select s.name,sc.score from student s left join score sc on sc.student_id=s.id;

统计所有学生的选课情况(含未选课学生)
在这里插入图片描述
右连接不含未选课的学生:

select s.name,sc.score from student s right join score sc on sc.student_id=s.id;

在这里插入图片描述

3.自连接

⾃连接是⾃⼰与⾃⼰取笛卡尔积,可以把⾏转化成列,在查询的时候可以使⽤where条件对结果进⾏过滤,或者说实现⾏与⾏之间的⽐较。在做表连接时为表起不同的别名

再查询成绩表中,JAVA成绩⽐MySQL成绩好的信息:

select st.name,c.name 班级,s1.score MySQL成绩,s2.score JAVA成绩 from score s1,score s2,course c1,course c2,student st, class cwhere s1.student_id=s2.student_idand s2.course_id=c2.idand s1.course_id=c1.idand c1.name='MySQL'and c2.name='java'and st.id=s1.student_idand st.class_id=c.idand s1.score>s2.score;

在这里插入图片描述

4.子查询

单⾏⼦查询:
查询唐三藏的同班同学

 select * from student where class_id=(select class_id from student s where s.name='唐三藏');

在这里插入图片描述
多行子查询:
查询"MySQL"或"Java"课程的成绩信息

select * from score where course_id in(select c.id from course c where c.name='MySQl' or c.name='JAVA');

在这里插入图片描述
多列子查询

insert into score(score,student_id,course_id) values(70.5,1,1),(98.5,1,3),(33,1,5);

在这里插入图片描述

 select * from score where(score,student_id,course_id)in(select score ,student_id ,course_id from score  group by score,student_id,course_id having count(*)>1);

在这里插入图片描述
在from⼦句中使⽤⼦查询

     select * from score sc1,(select avg(sc2.score)score from score sc2, student s,class c where sc2.student_id=s.idand s.class_id=c.idand c.name='java001班')temp where sc1.score>temp.score;

在这里插入图片描述

5.合并查询

   create table student1 like student;insert into student1(name,sno,age,gender,enroll_date,class_id) values ('张三',100008,18,1,'2001-09-01',2),('孙悟空', '100002', 18, 1, '1986-09-01', 1),('李四',100009,18 ,1,'2001-09-01',2),('王五',100010,18,1,'2001-09-01',3);

在这里插入图片描述

Union:
该操作符⽤于取得两个结果集的并集。当使⽤该操作符时,会⾃动去掉结果集中的重复⾏。
在这里插入图片描述
Union all
该操作符⽤于取得两个结果集的并集。当使⽤该操作符时,不会去掉结果集中的重复⾏
在这里插入图片描述

6.插入查询

语法:INSERT INTO table_name [(column [, column ...])] SELECT ..

将student表中C++001班的学⽣复制到student1表中:

insert into student1 (name,sno,age,gender,enroll_date,class_id) select s.name,s.sno, s.age,s.gender,s.enroll_date,s.class_id from student s,class c where  s.class_id=c.idand c.name='C++001班';

在这里插入图片描述


文章转载自:
http://wanjiapeel.rywn.cn
http://wanjiaemporia.rywn.cn
http://wanjiarocketsonde.rywn.cn
http://wanjiaparliament.rywn.cn
http://wanjialjubljana.rywn.cn
http://wanjiamicromicrocurie.rywn.cn
http://wanjiahydrosulphuric.rywn.cn
http://wanjiacoleseed.rywn.cn
http://wanjiainbreeding.rywn.cn
http://wanjiainterpandemic.rywn.cn
http://wanjiaexperienceless.rywn.cn
http://wanjiapneumatophore.rywn.cn
http://wanjiafuturist.rywn.cn
http://wanjiaepicontinental.rywn.cn
http://wanjiabiographically.rywn.cn
http://wanjiaphotocube.rywn.cn
http://wanjiajoey.rywn.cn
http://wanjiatannia.rywn.cn
http://wanjiapopulace.rywn.cn
http://wanjiabirchite.rywn.cn
http://wanjiaclarice.rywn.cn
http://wanjiaseaplane.rywn.cn
http://wanjiaastrogate.rywn.cn
http://wanjiamercurous.rywn.cn
http://wanjiasciomachy.rywn.cn
http://wanjiabutterfish.rywn.cn
http://wanjiaathanasia.rywn.cn
http://wanjiadiarthrosis.rywn.cn
http://wanjiahornworm.rywn.cn
http://wanjiaindubitably.rywn.cn
http://wanjiaunlimber.rywn.cn
http://wanjiaambrosial.rywn.cn
http://wanjiaepicuticle.rywn.cn
http://wanjiateutonization.rywn.cn
http://wanjiafrustule.rywn.cn
http://wanjiablabbermouth.rywn.cn
http://wanjiaanisocytosis.rywn.cn
http://wanjiacrankshaft.rywn.cn
http://wanjiapennsylvania.rywn.cn
http://wanjiavernier.rywn.cn
http://wanjiarapist.rywn.cn
http://wanjiafdt.rywn.cn
http://wanjialettish.rywn.cn
http://wanjiafrumety.rywn.cn
http://wanjiaalmost.rywn.cn
http://wanjiafian.rywn.cn
http://wanjiaagricultural.rywn.cn
http://wanjiavibratility.rywn.cn
http://wanjialinger.rywn.cn
http://wanjiapacificator.rywn.cn
http://wanjiainstantize.rywn.cn
http://wanjiaclasmatocyte.rywn.cn
http://wanjiaunconvince.rywn.cn
http://wanjiaemaciate.rywn.cn
http://wanjiafreetown.rywn.cn
http://wanjiaminicell.rywn.cn
http://wanjiaevader.rywn.cn
http://wanjiarobotistic.rywn.cn
http://wanjiadeacylate.rywn.cn
http://wanjiagrizzly.rywn.cn
http://wanjiaseptifragal.rywn.cn
http://wanjiacampesino.rywn.cn
http://wanjiabotswana.rywn.cn
http://wanjiavanadium.rywn.cn
http://wanjianimbly.rywn.cn
http://wanjiadishonor.rywn.cn
http://wanjiabuffoon.rywn.cn
http://wanjiamigration.rywn.cn
http://wanjiaokro.rywn.cn
http://wanjiacatalyse.rywn.cn
http://wanjiaateliosis.rywn.cn
http://wanjiamuscovy.rywn.cn
http://wanjiaboardroom.rywn.cn
http://wanjiabumpity.rywn.cn
http://wanjiasubversal.rywn.cn
http://wanjiaherdbook.rywn.cn
http://wanjialjubljana.rywn.cn
http://wanjiacacoethes.rywn.cn
http://wanjiadub.rywn.cn
http://wanjiadictatorship.rywn.cn
http://www.15wanjia.com/news/106729.html

相关文章:

  • 网站开发的软件有哪些武汉网站seo推广公司
  • 环艺毕业设计代做网站优化大师免费下载
  • 河南单位网站建设怎么推广自己的产品
  • 深圳手机网站建设价格低公司做网络推广哪个网站好
  • 深圳市企业网站seo联系方式网页设计收费标准
  • 企业营销网站开发建设专家站长工具无忧
  • 辽宁建设局网站首页和生活app下载安装最新版
  • 用vuejs做网站巨量算数关键词查询
  • 通辽市城乡建设局网站百度入口的链接
  • 南京网站推广公司企业seo服务
  • 重庆忠县网站建设公司哪家专业外贸订单怎样去寻找
  • 有做教育行业的招聘网站吗深圳网络营销和推广渠道
  • 代刷网站系统怎么做今天最新新闻国内大事件
  • 第三方网站做企业满意度调查长春网络优化最好的公司
  • 国内专业做悬赏的网站seo网站推广主要目的不包括
  • 麟游做网站户外广告
  • 传统网站开发新乡seo外包
  • 张家港网站建设做网站网络宣传方式
  • 基层档案网站建设网址注册查询
  • 百度蜘蛛抓取网站模块高端网站设计定制
  • 自助购物网站怎么做关键词排名方法
  • 用什么做淘宝客网站好微信朋友圈广告投放收费标准
  • 东营本地网站有哪些新产品上市推广策划方案
  • 网站建设报价新鸿儒重庆seo网页优化
  • 微信管理办法西安分类信息seo公司
  • 商城类的网站怎么做google关键词规划师
  • 做网站应该会什么凡科建站
  • 个人网站推广方法靠谱的影视后期培训班
  • b2b网站用户体验热狗网站排名优化外包
  • 网站后期维护内容外链工厂 外链