码迷,mamicode.com
首页 > 数据库 > 详细

优化Myschool数据库设计联合、联接、子查询

时间:2015-01-14 13:58:54      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

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‘)

优化Myschool数据库设计联合、联接、子查询

标签:

原文地址:http://www.cnblogs.com/Thefuture/p/4223620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!