没必要用到谓词演算。用以下的查询:
select sno,from sc
where cno in
(select cno from sc
where sno='95002'
)
group by sno
having count(*)=(select count(*) from sc
where sno='95002')在SQL server 2000中调试通过。
select sno,from sc
where cno in
(select cno from sc
where sno='95002'
)
group by sno
having count(*)=(select count(*) from sc
where sno='95002')在SQL server 2000中调试通过。
你查找的是两人选了相同的课,我要查的是至少选了95002 同学选的所有课的
同学学号。如果95002 选了c01,c02,c03;而95001 选了c01,c02,c03,c04四门课,你的程序好象查不出来了。再指点一下 : )
再指点一下.
步兄的代码是可以的,本人以前也是这样用的。另外步兄的代码处好象是多了一个逗号,应该是:
select sno from sc
where cno in
(select cno from sc
where sno='95002'
)
group by sno
having count(*)=(select count(*) from sc
where sno='95002')如果结果仍然不对,那可能是你的数据问题,比如数据中含有空格之类的。