需要记忆的几个sql语句
链接查询:
1.查询两个表,在where中定义连接条件:
select student.sno,sname,ssex,sage,sdept,cno,grade.
from student,sc
where student.sno=sc.sno;
2.用Join在from中指定链接条件:
select student.sno,sname.ssex,sage,sdept,cno,grade
from student join sc on (student.sno=sc.sno)
3.比较复杂的查询条件
select student.sno,sname
from student.join sc on student.sno = sc.sno
where sc.cno='2' and sc.grade>90
4.多表查询:
select student.sno,sname,cname,grade
from student,sc,course
where student.sno = sc.sno and sc.cno =course.cno;
5.查询选修了数据库系统原理课程的同学的学号和姓名和成绩:
select student.sno,sname,grade
from student,course,sc
where student.sno=sc.sno and course.cno = sc.cno and cname='数据库系统原理'