SQL问题,大家看看!(20分)

  • 主题发起人 hurryman
  • 开始时间
H

hurryman

Unregistered / Unconfirmed
GUEST, unregistred user!
S(sno,sname,sex,age,dept,special);//系表
c(cno,cname,credit,dept,precno,tno);//课程
sc(sno,cno,grade);//成绩
//////////////////////////////////////
检索选修了计算机系全不课程的学生姓名,学号
select sno ,sname
from s,sc
where s.sno=sc.sno and s.sno in (
select sno
form sc
group by sno
having count(*)=count(
select distinct cno
from c
)
)
不知道对不对,大家检查一下
 
语法无误,阅
 
select sno ,sname
form s
where not exitst
(select *
form c
where s.dept='jisuanji'
and not exists
(select *
form sc
where s.sno=sc.sno and sc.cno=c.cno))

select sno ,sname
from s,sc
where s.sno=sc.sno and s.dept='jisuanji' and s.sno in (
select sno
form sc
group by sno
having count(*)=count(
select distinct cno
from c
)
)
两者的到的结果有区别吗?
 
自己弄个数据库来试试不就行了,又不疑难杂症浪费分数,懒是学不到东西的。
 
大致看了一下,没什么问题.
//最好是自己试试,增加自己的经验好些的.
 

Similar threads

顶部