查询至少选修了两门课程的学生学号的sql语句

第一个:至少选修c1和c2的学生编号
           1.  select sno from sc where sc.cno='c1' and sno in(select sno from sc where cno='c2')
           2.select sno from sc scx,sc scy where scx.sno=scy.sno and scx.cno='c1' and scy.cno='c2'
 
第二个:同时选修c1和c2的学生编号
             select sc.sno from sc where sc.cno = 'c1' intersect select sc.sno from sc where sc.cno= 'c2';

转载于:https://www.cnblogs.com/sunshine-study/p/3645657.html

你可能感兴趣的:(查询至少选修了两门课程的学生学号的sql语句)