150分求教VFP SQL语句

xymdk 2003-10-17 08:42:47
有3个表:
s(xh,xm)(学号\姓名)
c(kch,khm,ls)(课程号\课程名\老师)
sc(xh,kch,cj)(学号\课程好\成绩)
现在要查询的是:选修全部课程的学生姓名.
select s.xm
from s
where not exists
(sele *
from sc
where not exists
(sele *
from c
where sc.xh=s.xh and sc.kch=c.kch));

VFP6中写此语句,说嵌套太深,有简单的语句实现或怎么实现?
...全文
42 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ishxb 2003-10-18
  • 打赏
  • 举报
回复
友情帮顶
xymdk 2003-10-17
  • 打赏
  • 举报
回复
都不是好办法?还有更好的嘛?一个语句可以解决嘛?
520zyb 2003-10-17
  • 打赏
  • 举报
回复
更改最后一句:select xm,count(xh) from t1 where count(xh)=num.num group by xh
520zyb 2003-10-17
  • 打赏
  • 举报
回复
select count(kch) as num from c into cursor num
select s.xh,xm,kch from s,sc where s.xh=sc.xh into cursor t1
select xm,count(xm) from t1 where count(xm)=num.num group by xm
mgan 2003-10-17
  • 打赏
  • 举报
回复
sele count(kch)as a1 from c into cursor t1
sele max(a1) as maxch1 form t1 into array c1
sele cout(kch) as a2 form sc group by kch into cursor t2
sele max(a2) as maxkch2 form t2 into array c2
sele xh,xm form a where c1=c2


这样 麻烦一点但是不会嵌套太深
huntertiger 2003-10-17
  • 打赏
  • 举报
回复
select sc.xh,s.xm from sc join s on sc.xh=s.xh group by sc.xh having count(*)=(select count(*) from c group by kch)

2,722

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧