distinct去掉重复
select * from student,sc;
学生表和选课表用逗号连接得到学生表和选课表的笛卡尔积
select * from student join sc on student.sno=sc.sno;
用连接动词连接起来得到的是关系代数里的连接操作(等值连接)
select * from student,sc where student.sno=sc.sno;
学生表学号与选课表学号相等
select * from student,sc where student.sno=sc.sno and sname=‘利用’ and cno=1;
select grade from student,sc where student.sno=sc.sno and sname=‘利用’ and cno=1;
查询利用数据库的成绩
select * from student,course,sc;
学生表课程表选课表的笛卡尔积
select * from student,course,sc where student.sno=sc.sno and sc.cno=course.cno;
select grade from student,course,sc where student.sno=sc.sno and sc.cno=course.cno and sname=‘利用’ and cname=‘数据库’;
select * from student join sc on student.sno=sc.sno;
select * from student join sc on student.sno=sc.sno join course on sc.cno=course.cno;
select * from student join sc on student.sno=sc.sno join course on sc.cno=course.cno where sname=‘利用’ and cname=‘数据库’;
多表查询
最新推荐文章于 2023-03-24 14:46:29 发布