这个sql语句怎么写?????????

来源:百度知道 编辑:UC知道 时间:2024/05/24 12:13:26
有表sc
sno(学号) cno grade
s1 c1 75
s1 c2 12
s1 c3 44
s2 c4 55
s3 c2 15
s3 c1 46
s4 c3 45
s4 c1 75
问:查找同时选修了c1和c2课程的学生学号

SELECT sno
FROM sc
WHERE (cno = 'c1') AND (sno IN
(SELECT sno
FROM sc
WHERE cno = 'c2'))

SELECT SNO from (SELECT SNO FROM sc WHERE cno='c1' or cno='c2') group by sno having count(sno)>=2

select sno from sc where cno="C1" and cno="C2";
不就这样吗 都写那么复杂 知道的很多啊

select t1.sno from (select * from sc where cno='c1') t1,(select * from sc where cno='c2') t2 where t1.sno=t2.sno ;

select sno from sc where cno="C1" and cno="C2";

select sno from sc where cno in ('c1','c2');