USE MySchool
go
--联合查询:合并多个数据集中的行
SELECT StudentNo,SubjectNo,StudentResult From Result
--UNION
SELECT SubjectNo,ClassHour,GradeID From Subject
--联接查询:合并多个数据集中的列
SELECT StudentName AS 姓名,SubjectNo AS 课程编号,StudentResult AS 成绩
FROM Student INNER JOIN Result ON Student.StudentNo = Result.StudentNo
--子查询:偏重于筛选符合条件的记录
SELECT * FROM Student WHERE GradeId =
(SELECT GradeId FROM Grade WHERE GradeName = ‘S1‘)
时间: 2024-10-09 01:34:02