标签:外连接 each 根据 实例 通过 ros select course tno
对sc和student表进行内连接,显示学生的学号,姓名,课程号,分数。
语法1:
select student.sno,student.sname,sc.sno,sc.grage from sc join student on sc.sno=student.sno
语法2:
select student.sno,student.sname,sc.sno,sc.grage from sc,student where sc.sno=student.sno
显示学生的学号,姓名,课程名,考试分数
语法1:
select student.sno,student.sname,course.cname,sc.grage from sc join student on sc.sno=student.sno join course on sc.sno=course.sno
语法2:
select student.sno,student.sname,course.cname,sc.grage from sc,student,course where sc.sno=student.sno and sc.sno=course.sno
让student表和sc表进行左外连接,即不管是学生是否有选修课程,该学生的信息的都会显示出来
select student.sno,student.sname,sc.sno,sc.grade from student left outer join sc on student.sno=sc.sno
让sc表和teacher表进行右外连接,显示教师编号,教师姓名,讲师教授的课程号
select teacher.tno,teacher.tname,sc.cno from sc right outer join teacher on sc.tno=teachaer.tno
让sc表和teacher表进行全外连接,显示教师编号,教师姓名,讲师教授的课程号。
teacher.tno,teacher.tname,sc.cno from sc full outer join teacher on sc.tno=teacher.tno
让学生和课程两张表进行交叉连接
select *from student cross join course
标签:外连接 each 根据 实例 通过 ros select course tno
原文地址:https://www.cnblogs.com/dongxuelove/p/12945683.html