常用查询语句例题。

1.查询所有学生的Sname、Cname和Degree列。
select Sname,Cname,Degree from student1 t1 join Score t2 on t1.Sno=t2.Sno join course t3 on t2.Cno=t3.Cno

(最基本的连接查询  join   on)

2.查询score中选学多门课程的同学中分数为非最高分成绩的记录。
select * from Score a where sno in (
select Sno from Score group by Sno having count(1)>1)
and a.Degree<(select max(Degree) from Score b where a.Cno=b.Cno  )

(这个查询我理解的就是子查询加上连接查询)

posted on 2017-10-27 14:52  小败哥哥。  阅读(115)  评论(0编辑  收藏  举报

导航