ITPub博客

首页 > IT职业 > IT图书 > 嵌套子查询

嵌套子查询

IT图书 作者:solution 时间:2021-09-09 09:14:14 0 删除 编辑

-项目一.
--开发学生选课表中状态为报名,的课程名称有哪些?
--需要查询( 课程表 )( 选课表 )表?
--子查询的对象( 课程表中为报名的 )
--使用的查询方法(子查询 )

--第一步.查询课程表和学生选课表
select from Course
select
from StuCou

--第二步.查询学生选课表,报名状态是报名的课程编号
select couno from StuCou
where State='报名'

--第三步.使用纵向嵌套子查询查询结果
select stuno,stuname
from Student
where exists (select StuNo
from StuCou
where StuNo=student.StuNo and State='报名')

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2459/viewspace-2800911/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-05

  • 博文量
    101
  • 访问量
    21774