suflowers1700218

连接查询:

内连接(inner join):查询两张表中同时拥有的数据。(交集)

左连接(left join):以左侧表为主表。

右连接(right join):以右侧表为主表。

全连接(full join):存在于表a或表b中的数据。(并集)

交叉连接(across join):返回连接操作的两张表中所有数据行的笛卡尔积,得到的结果集的行数是两个表行数的乘积。

 

--UNION (并操作) 查询选了课程17C0117C02的学生编号 --无重复值(会做筛选)

 

select StudentNO from StudentCourse where CourseNo=\'17C01\' UNION select StudentNO from StudentCourse where CourseNo=\'17C02\'

--有重复值(会列出所有的值)

select StudentNO from StudentCourse where CourseNo=\'17C01\' UNION ALL select StudentNO from StudentCourse where CourseNo=\'17C02\'

--INTERSECT (交操作) 查询选了课程17C0117C02的学生编号

select StudentNO from StudentCourse where CourseNo=\'17C01\' INTERSECT select StudentNO from StudentCourse where CourseNo=\'17C02\'

--EXCEPT (差操作) 查询选了课程17C01,没选课程17C02的学生编号

select StudentNO from StudentCourse where CourseNo=\'17C01\' EXCEPT select StudentNO from StudentCourse where CourseNo=\'17C02\'

 

 

 

 

 

 

分类:

技术点:

相关文章:

  • 2021-11-11
  • 2021-11-28
  • 2021-11-01
  • 2021-08-29
  • 2021-08-29
  • 2021-11-01
  • 2021-11-01
  • 2021-12-29
猜你喜欢
  • 2021-10-27
  • 2021-10-17
  • 2021-11-01
  • 2021-11-01
  • 2021-11-01
相关资源
相似解决方案