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

做网站培训青海省住房和城乡建设厅的官方网站

做网站培训,青海省住房和城乡建设厅的官方网站,网页制作与网站建设答案,深圳网站制作公司MySQL50-4-第6-10题本文中介绍的是第6-10题#xff0c;涉及到的主要知识点#xff1a;模糊匹配和通配符使用表的自连接in/not in连接查询的条件筛选image题目6题目需求查询“李”姓老师的数量分析过程使用通配符和like来解决SQL实现select count(t_name) from Teacher where …MySQL50-4-第6-10题本文中介绍的是第6-10题涉及到的主要知识点模糊匹配和通配符使用表的自连接in/not in连接查询的条件筛选image题目6题目需求查询“李”姓老师的数量分析过程使用通配符和like来解决SQL实现select count(t_name) from Teacher where t_name like 李%; -- 通配符image这题怕是最简单的吧题目7image题目需求查询学过张三老师授课的同学的信息分析过程张三老师Course---t_name课程c_id------Score.c_id-------Student.*SQL实现-- 方法1通过张三老师的课程的学生来查找自己的方法select * -- 3. 通过学号找出全部学生信息from Studentwhere s_id in (select s_id -- 2.通过课程找出对应的学号from Score Sjoin Course Con S.c_id C.c_id -- 课程表和成绩表where C.t_id(select t_id from Teacher where t_name张三) -- 1.查询张三老师的课程);-- 方法2通过张三老师的课程来查询select s1.*from Student s1join Score s2on s1.s_ids2.s_idwhere s2.c_id in (select c_id from Course c where t_id( -- 1. 通过老师找出其对应的课程select t_id from Teacher t where t_name张三))-- 方法3select s.* from Teacher tleft join Course c on t.t_idc.t_id -- 教师表和课程表left join Score sc on c.c_idsc.c_id -- 课程表和成绩表left join Student s on s.s_idsc.s_id -- 成绩表和学生信息表where t.t_name张三;自己的方法image方法2来实现image方法3实现image题目8题目需求找出没有学过张三老师课程的学生分析过程和上面的题目是互补的考虑取反操作SQL实现select * -- 3. 通过学号找出全部学生信息from Studentwhere s_id not in ( -- 2.通过学号取反学号不在张三老师授课的学生的学号中select s_idfrom Score Sjoin Course Con S.c_id C.c_idwhere C.t_id(select t_id from Teacher where t_name 张三) -- 1.查询张三老师的课程);-- 方法2select *from Student s1where s1.s_id not in (select s2.s_id from Student s2 join Score s3 on s2.s_ids3.s_id where s3.c_id in(select c.c_id from Course c join Teacher t on c.t_idt.t_id where t_name张三));-- 方法3select s1.*from Student s1join Score s2on s1.s_ids2.s_idwhere s2.c_id not in (select c_id from Course c where t_id( -- 1. 通过老师找出其对应的课程select t_id from Teacher t where t_name张三));image方法2image题目9image题目需求查询学过编号为01并且学过编号为02课程的学生信息分析过程课程编号Score——c_id(课程编号)学生信息Student——*(学生信息)SQL实现-- 自己的方法通过自连接实现select s1.*from Student s1where s_id in (select s2.s_id from Score s2join Score s3on s2.s_ids3.s_idwhere s2.c_id01 and s3.c_id02);-- 方法2直接通过where语句实现select s1.*from Student s1, Score s2, Score s3where s1.s_ids2.s_idand s1.s_ids3.s_idand s2.c_id01 and s3.c_id02;-- 方法3两个子查询-- 1. 先查出学号select sc1.s_idfrom (select * from Score s1 where s1.c_id01) sc1,(select * from Score s1 where s1.c_id02) sc2where sc1.s_idsc2.s_id;-- 2.找出学生信息select *from Studentwhere s_id in (select sc1.s_id -- 指定学号是符合要求的from (select * from Score s1 where s1.c_id01) sc1,(select * from Score s1 where s1.c_id02) sc2where sc1.s_idsc2.s_id);先从Score表中看看哪些人是满足要求的01-05同学是满足的image通过自连接查询的语句如下image查询出学号后再匹配出学生信息image通过where语句实现image方法3的实现image题目10题目需求查询学过01课程但是没有学过02课程的学生信息(注意和上面题目的区别)分析过程使用的表和字段是相同的课程编号Score——c_id(课程编号)学生信息Student——*(学生信息)SQL实现首先看看哪些同学是满足要求的只有06号同学是满足的image错误思路1直接将上面一题的结果全部排出导致那些没有学过01课程的学生也出现了0708select s1.*from Student s1where s_id not in ( -- 直接将上面一题的结果全部排出导致那些没有学过01课程的学生也出现了0708select s2.s_id from Score s2join Score s3on s2.s_ids3.s_idwhere s2.c_id01 and s3.c_id 02);image错误思路2将上面题目中的02课程直接取反导致同时修过010203或者只修0103的同学也会出现select s1.*from Student s1where s_id in (select s2.s_id from Score s2join Score s3on s2.s_ids3.s_idwhere s2.c_id01 and s3.c_id !02 -- 直接取反是不行的因为修改(01,02,03)的同学也会出现);image正确思路-- 方法1根据两种修课情况来判断select s1.*from Student s1where s1.s_id in (select s_id from Score where c_id01) -- 修过01课程要保留and s1.s_id not in (select s_id from Score where c_id02); -- 哪些人修过02需要排除image方法2先把06号学生找出来select * from Student where s_id in (select s_idfrom Scorewhere c_id01 -- 修过01课程的学号and s_id not in (select s_id -- 同时学号不能在修过02课程中出现from Scorewhere c_id02));select s_idfrom Scorewhere c_id01 -- 修过01课程的学号and s_id not in (select s_id -- 同时学号不能在修过02课程中出现from Scorewhere c_id02)imageimage如何找出06号学生如何Score中找出06号学生imageimage
http://www.zqtcl.cn/news/802477/

相关文章:

  • 注册公司多少钱不用交税南昌seo网站推广费用
  • 网站建设与运营的论文的范本wordpress弹框登陆
  • 阿里云做的网站空间动画制作器
  • 徐州企业网站建设做视频网站需要多少上传
  • 记事本做网站怎么加背景图网站开发需要哪些人怎么分工
  • 南宁网站建设找哪家网站被k换域名
  • spring mvc 网站开发网站开发与管理所对应的职位及岗位
  • 国内做视频的网站有哪些宁波网站制作与推广
  • 织梦软件展示网站源码建设工程竣工验收消防备案网站
  • 网站里面的链接怎么做漳州建设网站
  • 有什么网站建设类岗位企业门户网站设计论文
  • 外贸公司如何做公司网站集团网站建设建站模板
  • 嘉兴云推广网站贵州毕节网站建设
  • 班级网站模板青岛哪里有做网站公司的
  • 建设工程设计招标信息网站.制作一个聊天软件需要多少钱
  • 校园网站建设的意见新闻聚合网站开发 技术
  • 网站推广公司兴田德润电话多少wordpress 弹框
  • 大连网站建设谁家好软件开发需要什么技术
  • 广州网站建设哪家便宜成都电商app开发
  • 网站qq访客统计青岛网站设计定制
  • 山东嘉祥做网站的有哪几家销售外包
  • 怎么做网站_旅游网站定位
  • 湛江seo推广公司aso优化渠道
  • 网站设计培训机构内蒙古网上办事大厅官网
  • 什么是网站空间信息网站备案号中信息有变
  • 网站建设的基础怎么提升网站流量
  • 网站开发线框网页设计网站建设过程报告
  • 怎么用html做移动网站吗免费装修设计软件
  • 门头沟石家庄网站建设鞍山怎么样做一个自己的网站
  • 网站安装代码宣传网站建设背景