你是要找甲的所有记录 还是要找pno为1,2,3的人? 如果是前者 select * from table where sno='甲'
select sno from sp where sno='甲' and sno in ('1','2','3')
select sno from sp表 A ,(select 1 as Pno union select 2 union select 3) B where A.pno=B.pno group by Sno having count(*)=3
全学全部课程的人:select * from sp where 学号 not in( select 学号 from sp 别名 where not exists(select 1 from ( select * from (select distinct 选修课程号 from sp) a,(select distinct 学号 from sp) b) tem1 where 选修课程号=别名.选修课程号 and 学号=别名.学号))
还是要找pno为1,2,3的人?
如果是前者
select * from table where sno='甲'
select 学号 from sp 别名 where not exists(select 1 from (
select * from (select distinct 选修课程号 from sp) a,(select distinct 学号 from sp) b) tem1
where 选修课程号=别名.选修课程号 and 学号=别名.学号))