实现集合交运算,查询既选修课程C++又选修课程JAVA的学生的编号、姓名和积分。

解决方案 »

  1.   

    并集是这样的
    SELECT ZY_Students.ZY_Sno,ZY_Sname,(1+(ZY_Score-60)*0.1)*ZY_Ccredit
    FROM ZY_Students,ZY_Courses,ZY_Reports
    WHERE ZY_Cname='JAVA'  AND ZY_Reports.ZY_Cno=ZY_Courses.ZY_Cno AND ZY_Reports.ZY_Sno=ZY_Students.ZY_Sno
    UNION
    SELECT ZY_Students.ZY_Sno,ZY_Sname,(1+(ZY_Score-60)*0.1)*ZY_Ccredit
    FROM ZY_Students,ZY_Courses,ZY_Reports
    WHERE ZY_Cname='C++'  AND ZY_Reports.ZY_Cno=ZY_Courses.ZY_Cno AND ZY_Reports.ZY_Sno=ZY_Students.ZY_Sno
    但是交集用intersect或and都说有语法错误啊!!
      

  2.   

    http://topic.csdn.net/u/20100517/17/b2ab9d5e-73a2-4f54-a7ec-40a5eabd8621.html--9、查询学过编号为"01"并且也学过编号为"02"的课程的同学的信息
      

  3.   

    用and或者union操作就可以吧。具体的楼主贴点数据来看看吧。
      

  4.   

    select <字段一>,<字段二>,<字段3> from <表>  where   <选修课字段> in ('C++','JAVA')
      

  5.   

    select * from 表 where 课 = 'C++' and exists ( select 1 from 表 where 课 = 'JAVA')
    自己改一下就行
    或者
    select 名字 from 表 where 课 in ('C++','Java') group by 名字 having count(*)=2
      

  6.   

          
    select 你要的字段 from 选课表 A,学生表 B where A.name=b.name and A.Cname='C++' 
    and A.Cname in(select 1 from 选课表 A,学生表 B where A.name=b.name and A.Cname='java')