去面试遇上的一个题目,居然做不出来,丢脸啊
很简单的一个问题
三个表
学生S:
学号 姓名
SNO SNAME
课程C:
课程号 课程名
CNO CNAME
学生选课S-C
学号 课程号 成绩
SNO CNO SCORE
填空题,在(1)(2)(3)中填入相应的语句
得出选了所有课程的学生的名字
select sname
from s
where (1)
(select *
from c
where (2)
(select *
from s-c
where (3)
)
)
我做不出来,惭愧
高手指点一下
谢谢
问题点数:20、回复次数:29Top
1 楼didoleo(冷月无声)回复于 2005-01-03 19:21:51 得分 20
select sname
from s
where (not exists)
(select *
from c
where (not exists)
(select *
from s-c
where (sno=s.sno and cno=c.cno)
)
)
Top
2 楼didoleo(冷月无声)回复于 2005-01-03 19:23:04 得分 0
非常经典的一道集合算法,考的是双 not existsTop
3 楼78hgdong(赤脚)回复于 2005-01-03 19:26:03 得分 0
学习,顶!Top
4 楼didoleo(冷月无声)回复于 2005-01-03 19:28:44 得分 0
(1) not exists
(2) not exists
(3) sno=s.sno and cno=c.cno
--实际运行环境当中要把 not exists 的 ()拿掉
select sname
from s
where not exists
(select *
from c
where not exists
(select *
from s-c
where (sno=s.sno and cno=c.cno)
)
)
Top
5 楼didoleo(冷月无声)回复于 2005-01-03 19:31:30 得分 0
或者 把* 换成 1
select sname from s
where not exists
(select 1 from c
where not exists
(select 1 from s-c
where sno=s.sno and cno=c.cno)
)
Top
6 楼SARSII(八声)回复于 2005-01-03 20:16:06 得分 0
markTop
7 楼accumpzhu(夜色心情)回复于 2005-01-03 20:23:09 得分 0
正在读ACCP,正好遇到这个问题,解决方法与didoleo(冷月无声) 同
Top
8 楼xuhongying8848(偶遇-邂逅)回复于 2005-01-03 21:08:49 得分 0
markTop
9 楼631799(杭州工人)回复于 2005-01-03 22:14:06 得分 0
唉,把我们的脸丢光了~~
不分K我啊~~Top
10 楼gsh945(太平洋底)回复于 2005-01-03 22:16:58 得分 0
有点抽象阿,看了半天还是有点懵,哪位能指点指点?Top
11 楼panweiwebweb()回复于 2005-01-03 22:24:20 得分 0
mark tooTop
12 楼NinGoo(http://www.NinGoo.net)回复于 2005-01-03 23:36:55 得分 0
还不如叫我自己从头写来的容易写:)Top
13 楼SickNirvana(SickNirvana)回复于 2005-01-04 09:44:35 得分 0
正确
佩服
如果早点知道这个问题,我就进了那公司了,叹息啊
Top
14 楼long0104()回复于 2005-01-04 09:46:05 得分 0
1) not exists
(2) not exists
(3) sno=s.sno and cno=c.cno
--实际运行环境当中要把 not exists 的 ()拿掉
select sname
from s
where not exists
(select *
from c
where not exists
(select *
from s-c
where (sno=s.sno and cno=c.cno)
)
)
Top
15 楼gxh973121()回复于 2005-01-04 09:55:37 得分 0
markTop
16 楼xycleo()虚竹和尚()回复于 2005-01-04 10:25:43 得分 0
欢迎光临http://www.nocoer.com网站!一个web开发人员汇集的地方,每天都有精彩的技术贴子和文章!欢迎大家讨论!
每天都会有大量的供求信息发布!要做兼职的可以上来看看
noco赌场!可以在这里赚取大量的cp点数
noco考场!可以在这里证明你的开发能力
noco道具市场!购买你需要的道具!让noco更有意思
noco精灵市场!购买精灵为你作战!
noco = note + code + er
免费申请二级域名
地址:http://www.nocoer.com
注册的用户可以免费申请二级域名!
申请后,只要在电子简历当中填写自己的个人资料!就可以通过访问二级域名来访问您的简历
喜欢web开发的朋友多过来注册吧!
让我们一起构造一个最庞大的人才库Top
17 楼smalldeer(晓露)回复于 2005-01-04 13:28:21 得分 0
数据库概论中的一道经典的例子Top
18 楼xuweibo2005(xuweibo)回复于 2005-01-04 13:50:03 得分 0
高程的考题Top
19 楼lyx123(l_yx123)回复于 2005-01-04 14:16:22 得分 0
markTop
20 楼bluebillow()回复于 2005-01-04 14:16:30 得分 0
学习一下Top
21 楼Gfire(风之蓝歌)回复于 2005-01-04 17:58:56 得分 0
帮你顶Top
22 楼fongming()回复于 2005-01-04 18:32:39 得分 0
学习,顶!Top
23 楼gita(明)回复于 2005-01-04 18:39:18 得分 0
路过...Top
24 楼bibingpang(彬彬)回复于 2005-01-04 23:04:33 得分 0
懂了!Top
25 楼SickNirvana(SickNirvana)回复于 2005-01-05 10:35:05 得分 0
didoleo(冷月无声) 还有什么类似这种的经典例子吗
来一个教学贴吧
免得让我下次面试又吃亏Top
26 楼seayar(习习)回复于 2005-08-22 15:45:35 得分 0
markTop
27 楼jinder22(jinder22)回复于 2005-08-23 14:53:56 得分 0
select * from s,c where s.sno not in
(
select s.sno
from c,s
where not exists
(select *
from sc
where (sno=s.sno and cno=c.cno)
)
)
Top
28 楼jinder22(jinder22)回复于 2005-08-23 15:35:32 得分 0
select *
from s
where s.sno not in
(
select s.sno
from s,c
where s.sno not in
(select sc.sno
from sc
where (sno=s.sno and cno=c.cno)
)
)Top
29 楼luckyprg(lucky)回复于 2005-08-24 09:20:37 得分 0
MarkTop




