并集是这样的 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都说有语法错误啊!!
select <字段一>,<字段二>,<字段3> from <表> where <选修课字段> in ('C++','JAVA')
select * from 表 where 课 = 'C++' and exists ( select 1 from 表 where 课 = 'JAVA') 自己改一下就行 或者 select 名字 from 表 where 课 in ('C++','Java') group by 名字 having count(*)=2
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')
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都说有语法错误啊!!
自己改一下就行
或者
select 名字 from 表 where 课 in ('C++','Java') group by 名字 having count(*)=2
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')